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
infovariable inside quotes. - get html part of
divusinghtml()method without arguments. - set html
courseinfopassing html stringhtml(course2). - for more details, please read
.html() api documentation.
Comments
Post a Comment