Pergunta

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?

Foi útil?

Solução

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 +'">

Outras dicas

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

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 (".").

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top