Jquery: How To Get Attribute From An Object
I am having a problem getting the innerHTML from an object. At the moment I have this code: console.log( $(myString).find('#' + someID).prevObject ); myString is a string variabl
Solution 1:
You can get the HTML of an element via the jQuery html
function. So assuming the element with the ID really exists:
console.log( $(myString).find("#" + someID).html() );
That will give you what you said you wanted: The HTML of the li
with that id
. Note that I removed the prevObject
. Two reasons for that:
Solution 2:
You should get the html element from the jquery object like this:
console.log( $(myString).find("#" + someID).prevObject[0].innerHTML );
or you can access jquerys version of innerHTML
console.log( $(myString).find("#" + someID).prevObject.html() );
Solution 3:
Once you have the element you just need to use html().
$('div.demo-container').html();
See here for more information:-
Post a Comment for "Jquery: How To Get Attribute From An Object"