$(function(){
var z = document.body.children[0];
var x=$("li", z);
x.name="Johnny";
alert(x.prop(name));
});
x
should be an object containing all the elements within the firstul
in thebody
. Regardless of what the object contains, I would like to add a property with a value, and then use theprop()
method to show it - but that doesn't seem to work. Why is that?I saw a script containing the following:
var $x = $("div");
- Do I have to add$
to the variable name if it's a jQuery object?