简体   繁体   中英

How to get value of a HTML tag receiving from ajax call

I am receiving below html from vbscript page by ajax call.

<html>
<body>
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tbody>
            <tr>
                <td width="100%" valign="top">
                    <div id="xyz"></div>
                    <input name="a1" type="hidden" value="">
                    <input name="a2" type="hidden" value="586546d5">
                    <input name="a3" type="hidden" value="13025">
                    <br clear="all">
                </td>
            </tr>
        </tbody>
    </table>
</div>
</body>
</html>

Is it possible to get value of input tag where name="a2" in ajax. ie we want value 586546d5 in the variable.

您可以将html字符串转换为jquery对象,然后在其中获取元素:

$(returnehtml).find('[name=a2]').val();

使用查询选择器

document.querySelector('input[name=a2]').value

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM