Jquery set value for column column value

I am trying to set the value of a column column value. My jQuery looks like this:

$('tr td data-th=Name span').val('My span content...');

      

And my HTML looks like this:

<tr>
    <td data-th="Name"><span class="edit-input-text"></span>
    <input class="inp input-edit" type="text" name="location_name" value="Shepherds Bush"></td>
</tr>

      

I am trying to set the value span

so that it looks like this:

<span class="edit-input-text">My span content...</span>

+3


source to share


1 answer


You need to use

1) attribute value selector for targeting td with attribute value



2) span do not have value attribute. use .text()

to set the text of the span element.

$('tr td[data-th=Name] span').text('My span content...');

      

+1


source







All Articles