如何在javascript中获取html标记值(div) [英] How do I get html tag value (div) in javascript
本文介绍了如何在javascript中获取html标记值(div)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已在网站
http://www.phoneformat中实现了此功能(libphonenumber javascript)。 com /
如何获取此html标记返回的值。是或否
How do i get the value returned by this html tag. Whether Yes or No
< DIV id="phone_valid" class="popup-value"></DIV>'
我试过这个
function checkSubmit(){
var country=$("#phone_valid").val();
if(country=="No")
{
alert("Not a valid number");
return false;
}
到目前为止没有运气
推荐答案
.val()
方法主要用于获取表单元素的值,例如输入
,选择
和 textarea
。
The .val()
method is primarily used to get the values of form elements such as input
, select
and textarea
.
使用
$("#phone_valid").text();
获取DIV文本内容或
$("#phone_valid").html();
如果你想要加价。
这篇关于如何在javascript中获取html标记值(div)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文