title: Get Value of Table Row with Button Click Using jQuery - ASP.NET Core MVC
body: <p>I have a table inside of my view. I want to get the text from a row with a button click. So far I am not having any success. The most progress I've made is getting the responses &quot;[object object]&quot; and &quot;Extras 1&quot;. There's a value in my model named &quot;Extras&quot;, I don't know where the '1' came from.
  I've seen others use a hidden field to get the value, but still no luck.</p>
  <p>My goal is to use jQuery to get the text from the row with my button click. Thanks for your help!</p>
  <p>My View:</p>
  <pre><code>&lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;td&gt;Select&lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayNameFor(model =&gt; model.Extras)
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          @foreach (var item in Model)
          {
              &lt;tr&gt;
                  &lt;td&gt;
                      &lt;button class=&quot;btn btn-success&quot; id=&quot;btnSelect&quot;&gt;
                          @Html.HiddenFor(modelItem =&gt; item.Id)
                          Select
                      &lt;/button&gt;
                  &lt;/td&gt;
                  &lt;td id=&quot;tdExtras&quot;&gt;
                      @Html.DisplayFor(modelItem =&gt; item.Extras)
                      @Html.HiddenFor(modelItem =&gt; item.Extras);
                  &lt;/td&gt;
              &lt;/tr&gt;
          }
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  <p>in my jQuery I've tried to get the value with .val() and .text() - targeting &quot;Extras&quot; like:</p>
  <pre><code>$('#Extras').val();
  </code></pre>
  <p>to my understanding Extras is the ID. In the Chrome dev tools the html looks like:</p>
  <pre><code>&lt;button&gt;
      &lt;input id=&quot;#&quot; value=&quot;the text that I want to select&quot; /&gt;
  &lt;/button&gt;
  </code></pre>
  <p>I've also tried setting a class and id to the hidden field inside of my button. All of the values are there, but I can't get access to them. Please help.</p>