Reputation: 73
I have a class 'container' with an id.
<div class="container" id="1500"></div>
Now in my javascript I fetch the id with the following code:
$('.container:' + place).click(function(){
var id = $(this).attr('id');
});
Is there a possible way to link also a title in the class 'container'? If I debug my code and set a watch point on the attribute $(this), there is a field 'innerText' and field 'OuterText' with the value I want, but I can't fetch it.
Is there a possible way to get these attributes or can I pass a variable by initializing the container?
Upvotes: 0
Views: 58
Reputation: 33
i dont know if you can vincule that, maybe you can work with id only, and you can call via jquery for example if you have <div id="container1500"></div>
yu can call var val=$("#container1500").html();
check here
now if you have a dinamic var, you can use var val=$("#container" + i).html();
where "i" is a dinamic var, for example in for(var i =0 ;....
Upvotes: 1
Reputation: 3418
Yes, using jQuery you can access them using $(this)[0].innerText
and $(this)[0].outerText
Are you sure its a good idea to have an ID that starts with an integer and not a letter?
Upvotes: 0