FrozenHeart
FrozenHeart

Reputation: 20746

Can I create non-selfclosing tags via jQuery call

Can I create non-selfclosing tags via the following call in jQuery?

  let autorefreshLabel = $('<label/>', {
    text: 'Autorefresh after ' + autorefreshTimer + ' seconds...'
  });

Or is it possible to use this function for the self-closing tags like input only?

It works in Chrome, but I don't know whether it is guaranteed or not.

Upvotes: 2

Views: 34

Answers (1)

Kenneth
Kenneth

Reputation: 241

Jquery will just create the ending tag itself when you create an element like that. Just type eg $('') in you developer tools on you website that supports jquery and you'll see.

you can always refer to the jquery docs on creating elements: http://api.jquery.com/jQuery/#jQuery2

Upvotes: 5

Related Questions