Reputation: 43
i tried to search throught the html code for an element named scope using javascript. After that it should show a alertbox with the value of this element.
if($('[name=scope]').length > 0){
var scope = $(this).value();
alert(scope);
}
But that doesn't work for me. What can i do to fix this?
Thanks!
Upvotes: 0
Views: 29
Reputation: 148140
You need val()
instead of value()
, there is not value function in jQuery
var scope = $(this).val();
Or simply use this.value, that would be simple and faster
var scope = this.value;
Edit based on comments
$('[name=scope]').each(function(){
alert(this.value);
});
Upvotes: 1