Click here to Skip to main content
15,899,825 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I want to get element by its id of a label with same tag id by a button click event. But it only read the first elements value. If you can please give me a method how I can read all the values of labels. If you can please help me. Thank You.
Posted
Updated 12-Jun-12 18:33pm
v2
Comments
Sergey Alexandrovich Kryukov 13-Jun-12 0:30am    
"Same" should come with "as"; same as what? id is unique... Why would you need it, what's the ultimate goal? What's the difference how a label is identified? jQuery has selector for all cases. How it can be a problem? it looks trivial...
--SA
Jeremy Shin Woo 13-Jun-12 0:42am    
There are two table with same details. I want to update both label's value by a button click event in one table.

suppose u have label with id ="label1"

so to get its value on onclick just put that code into onclick function like

JavaScript
function getvalue()
{
var value=$("#label1").text();
}
 
Share this answer
 
v2
Jeremy Shin Woo - 13 Jun '12
There are two table with same details. I want to update both label's value by a button click event in one table.

Elsalmo 3likom,
Dear,
if you want to update both labels in two table give them same class
HTML
<label class="asd">fff</label>
<label class="asd">llll</label>

and in the click event write this code
JavaScript
//this line to set the two lable
$(".asd").text("ahmed");
//this line to get the two value
var x = $(".asd").text();

but, when you get the tow value you have to split them.

Best Regards
Ahmed Assaf
eBusiness Developer
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900