Click here to Skip to main content
14,735,092 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I fill table like this. I want toread value of span in jquery/javascript

<tr><td><span id="span1" >0.00</span></td>
<td><input onchange="display(this)" placeholder="0.00" />

 function display(lnk) {
            var row = lnk.parentNode.parentNode;
            var rowIndex = row.rowIndex - 1;
Updated 5-Oct-20 21:03pm
Sinisa Hajnal 8-Jan-16 6:25am
You cannot access template element because it doesn't exist in rendered page. Instead, see the source code of the page (in the browser) and target suitable id. You may have to change default id of the txtLiftedQty by adding rowID or index or something so it is unique on the page (unless the server is already doing it).

Finally, if your getelementbyid works, why do you need jQuery to access it? jQuery id access looks like $('#ID') will still have to create that id...or you could use the above code with getelementbyid and just wrap received object in jQuery (i.e. $(row) )
Member 7909353 8-Jan-16 6:44am
Like this
var row = document.getElementById(rowId + "_txtLiftedQty_" + rowIndex);

alert("abc=" + $('#row').val());
It shows abc=undifined
Member 7909353 8-Jan-16 6:54am
Actually I do not want to use innerHTML after getting element.
Member 7909353 8-Jan-16 7:04am
alert( gives
CMEDINAS 5-Feb-16 10:12am
youy can use... $("#span1").text()

you can use for read span

$(document.getElementById("tblEvent").rows[17].cells[0].innerHTML+' span').text()
Richard Deeming 6-Oct-20 5:24am
An unformatted, unexplained code-dump which uses exactly the same method as the existing solution.

You have added nothing to the discussion.

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