0

I have this code and I would like to know how to set id values to <h4> and know if the id is valid.

 container.insert({ bottom: '<h4 style="margin:8px 0px 4px 0px; padding-left:0px ; select id=comment_'+ l +'">' + l + '</h4>' });

I need this so I can hide/show this <h4> depending on the value of a combo box.

Or is there an easier way to do this?

john_science
  • 6,325
  • 6
  • 43
  • 60
user181891
  • 101
  • 1
  • 3
  • 12
  • You might want to see this question, http://stackoverflow.com/questions/70579/what-are-valid-values-for-the-id-attribute-in-html – Callum Jones Apr 13 '12 at 14:13
  • 1
    you can give an id to whatever you want, but not inside a `style` definition. The " before the > should be after the `0px ;`... and what is a 'select' inside an h4 definition? – Rodolfo Apr 13 '12 at 14:20
  • i dint saw the select in there ^^ can u post how the code should be? – user181891 Apr 13 '12 at 14:23

3 Answers3

1

Your attributes on the H4 appear to be malformed explaining why you cant navigate the to the h4 by an id selector

<h4 style="margin:8px 0px 4px 0px; padding-left:0px ; select id=comment_'+ l +'">

Should be

<h4 style="margin:8px 0px 4px 0px; padding-left:0px;" id="comment_'+ l +'">
Simon West
  • 3,708
  • 1
  • 26
  • 28
0

You can give an id attribute to any elements you like, even script/link/head and other tags.

GillesC
  • 10,647
  • 3
  • 40
  • 55
0

You can add an ID to any element you like. As for its validity:

ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

Jose Faeti
  • 12,126
  • 5
  • 38
  • 52