passing variables to an attribute in jquery -
how can pass variable in jquery this:
var info = $(this).attr("id"); var course2 = $('div[name=info]').html; $("#courseinfo").html(course2);
i having difficulty second line..
var info = $(this).attr("id"); var course2 = $('div[name="' + info + '"]').html(); $("#courseinfo").html(course2);
- put
info
variable inside quotes. - get html part of
div
usinghtml()
method without arguments. - set html
courseinfo
passing html stringhtml(course2)
. - for more details, please read
.html() api documentation
.
Comments
Post a Comment