From the context of the code I am reading, it seems like $("<tag></tag>") creates a tag, where as $('<tag>') is a selector that searches for a tag. What’s going on here? Actually I might not have the syntax of the second one right, but I’m sure I’ve done $('idName') like this before.
What’s going on?
The difference between
$("<tag></tag>")and$("<tag>")and$("<tag />")is personal style/preference (unless you’re using IE, apparently. see comment). All three will use the nativecreateElement()method to create a now DOM element. If the tags have parameters it will parse them create the element by some other means.More info on creating things here: http://api.jquery.com/jQuery/#jQuery2
To select elements by id, you’d use
$("#idName").To select existing elements by tag name,
$("tag").To select existing elements by class name,
$(".className").More info on selecting things here: http://api.jquery.com/jQuery/#jQuery1