1
How do I get the value 1 and manipulate - lo, by jquery, which is inside the td tag (I want this value to increase as I click an id button = 'add-Row'):
<td>1</td>
1
How do I get the value 1 and manipulate - lo, by jquery, which is inside the td tag (I want this value to increase as I click an id button = 'add-Row'):
<td>1</td>
2
You can use $('td').html()
to read and $('td').html('novo valor')
to change...
Depending on your HTML you should be more specific in the selector $('td')
because this way you will select the td
all. To increase the value each time an element is clicked you need to use an event receiver, and I suggest you keep that count in Javascript in the example below. But without knowing the rest of the code I can’t guess much more.
var contador = 0;
$('#add-row').on('click', function(){
contador++; // somar +1
$('td').html(contador);
});
Example: https://jsfiddle.net/tmx7bo52/
1
You can use custom filter. See:
var text = $("td").filter(function(){
return $(this).text() === "I";
}).text();
console.log("Text: " + text)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table><tr><td>I</td></tr></table>
thanks! I got it!
Browser other questions tagged jquery html
You are not signed in. Login or sign up in order to post.
I don’t understand, could be more specific?
– Emir Marques
sorry, forgot q the html tag was interpreted haha
– alexandre9865
You can use
$('td').html()
to read and$('td').html('novo valor')
to change... is that your question? If you explain your HTML better it is easier if only$('td')
go get thetd
all.– Sergio
I think yes, I will test..
– alexandre9865