Reputation: 3500
I need to get attributes from a hyperlink like:
<a href="/groups/49882348/edit#" id="toleft" w_command="add_holiday" w_controller="groups" w_id="49882348" w_type="POST"><<</a>
and I want to get w_command, what do I have to do in Javascript? I tried the following:
var lin = document.getElementById("#toleft");
var w_controller = lin.attr("w_controller");
But this won't work. Any suggestions?
Upvotes: 1
Views: 56
Reputation: 76774
@Kiranramchandran
got it for javascript, but for JQuery you'll be able to do this:
var lin = $("#toleft");
var w_controller = lin.attr("w_controller");
Upvotes: 2
Reputation: 4980
Using Jquery:
console.log($('#toleft')[0].attributes['w_controller']);
Upvotes: 0
Reputation: 2094
try this
var lin = document.getElementById("toleft");
var w_controller = lin.getAttribute("w_controller");
alert(w_controller);
Upvotes: 4