Whing Dela Cruz
asked on
Writing td on the table
Hi, Experts, I wish to write something on the td of the table whos id is myProlist3. How could I make it with the codes below? In the codes below, I want to do something like this td:eq(1).html = b;
<script>
$(function() {
$(document ).on("click","#myProlist3 button.NewQty14",function(){
let tr = $(this).closest('tr');
let a = tr.find('td:eq(0)').html();
let b = tr.find('input')[0].value;
//This is what i need
td:eq(1).html = b;
});
});
</script>
ASKER
Hi, sir, it's working but the problem is.. the entire row will be written. Is there anyway here that only the row index will be filled up? Thanks!
You can try with tr index too
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi, Julian, thank you so much, your code its working on my project, but I want to add one more question here, I want to change the background-color of the td like tr.find('td:nth-child(4)') .html = background-color: white;
$(document ).on("click","#myProlist3 button.NewQty14",function(){
let tr = $(this).closest('tr');
let a = tr.find('td:eq(0)').html();
let b = tr.find('td:eq(1)').html();
let c = tr.find('input')[0].value;
tr.find('td:nth-child(4)').html(c);
// I want to do like this
tr.find('td:nth-child(4)').html(background-color: white);
});
Why do you want to do this in script? Why not in CSS?
tr td:nth-child(4) {
background-color: white;
}
ASKER
Hi, Julian, Its hard for me to explain why I need it to do in script rather than in css. My project is still using css as well. All I can say here is thank you so much for your help and guide.
Open in new window