get element value using jquery

2020-02-07 10:07发布

问题:

How do I get the value of the cell with class EventAddress using jquery?

<table cellpadding="10" class ="EventDetail">
    <tr>
        <td class="TableFields">Who Should Enroll?:</td>
        <td>Everyone 18 and older who would like to attend</td>
    </tr>
    <tr>
        <td class="TableFields">Location:</td>
        <td class="EventAddress">1300 Albany Street,Beech Grove ,IN</td>
    </tr>
</table>

回答1:

If you with "value" mean the content of the td-element, then you could do:

$(".EventAddress").text();


回答2:

alert($('.EventAddress').html());

Basic example: http://jsfiddle.net/LMBsc/