JQuery - capture td value next to switch

I have the following dilemma: My HTML as such (this exists in a PL / SQL application.):

<table id="search_result_table">
<tr>

<input type=radio name="pv_select" value="'||lv_spriden_id||'"/>
<font face="Calibri" size=3><td id="spriden_id"     name="spriden_id">'||lv_spriden_id||'</td></font>'
<font face="Calibri" size=3><td id="last_name" class="c_last_name"     name="last_name">'||lv_spriden_last_name||'</td></font>
<font face="Calibri" size=3><td id="first_name" class = "c_first_name"     name="first_name">'||lv_spriden_first_name||'</td></font>
</tr>
</table>

I can get the selected switch value via:

$("input[name=pv_select]:checked").val()

However, I would like to get the cell value of the column "last_name" (which exists in the table next to the switch). How can I get this value (for the selected row using the switch) via jQuery?

I tried a few things but no one works:

$("input[name=pv_select]:checked").parent().siblings("td:eq(1)").text());    

Thanks in advance.

+3
source share
3 answers

HTML ; , DOM , , jQuery, DOM.

HTML:

<table id="search_result_table">
    <tr>
        <td>
            <input type=radio name="pv_select" value="'||lv_spriden_id||'"/>
        </td>
        <td id="spriden_id" name="spriden_id"><font face="Calibri" size=3>'||lv_spriden_id||'</font></td>
        <td id="last_name" class="c_last_name" name="last_name"><font face="Calibri" size=3>'||lv_spriden_last_name||'</font></td>
        <td id="first_name" class = "c_first_name" name="first_name"><font face="Calibri" size=3>'||lv_spriden_first_name||'</font></td>
    </tr>
</table>

jQuery, "" , :

$("input[name=pv_select]:checked").parent().siblings("td.c_last_name").text());

( , HTML : id HTML, , , id , .)

+2

td td

, , ,

$("input[name=pv_select]:checked").parent().siblings("td:eq(0)").text();

( , .siblings( "td: eq (1)" ) - , eq (0) )

..

html-, , . tr, tr - .

, .next(), DOM

, FF ( - Firebug/jquery ext.), , ( ):

$('input[name="pv_select"]:checked').next();

: font, FF ( - FireBug), .children() whatewer td,

0

I only realized that this works in Firefox, but not in IE. Therefore, I will analyze what might cause this loss of failure in one browser, and not in another.

0
source

Source: https://habr.com/ru/post/1729095/


All Articles