I have this code that someone else wrote and am wondering, what this jQuery code is selecting? Is this valid jQuery code?
var a = $("<h3/>").append($("<a/>", {
href : "/comic/title.html",
class : "comic-link"
}).text("comic-name"));
I have never seen HTML tags being used like <h3/>
or <a/>
.
"$("div p")" Selects all elements matched by <div> that contain an element matched by <p>.
The select() method is an inbuilt method in jQuery which is used when some letters or words are selected (or marked) in a text area or a text field. Syntax: $(selector). select(function);
The above snippet does not select anything, it creates DOM elements and subsequently manipulates them.
See here for the jQuery documentation of this method.
$("<h3/>"
creates a new h3 element$("<a/>", { attributes})
creates an <a/>
with those attributes.text()
appends the textvar a =
the whole un-attached newly created DOM element (wrapped in a jQuery object)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With