javascript - Setting href attribute at runtime -
what best way set href attribute of <a> tag @ run time using jquery?
also, how value of href attribute of <a> tag using jquery?
to or set attribute of html element, can use element.attr() function in jquery.
to href attribute, use following code:
var a_href = $('selector').attr('href'); to set href attribute, use following code:
$('selector').attr('href','http://example.com'); in both cases, please use appropriate selector. if have set class anchor element, use '.class-name' , if have set id anchor element, use '#element-id'.
Comments
Post a Comment