
<!DOCTYPE html>
<html>
<head>
<script src="js/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("#btn1").click(function(){
alert("Text: " + $("#test").text())
})
$("#btn2").click(function(){
alert("HTML: " + $("#test").html())
})
})
</script>
</head>
<body>
<p id="test">This is some <b>bold</b>text in a paragraph.</p>
<button id="btn1">Show Text</button>
<button id="btn2">Show HTML</button>
</body>
</html>
从js里面获取HTML 的input标签中的内容分两种:1、获取input标签的值,方法:
根据input的name或者id获取其值,假如有:<input type='text' id='name' value=123>
js中获取方法:$("#name").val()
2、获取input标签的属性内容,方法:
如有:<input type='text' id='name' value=123 ind='1'>
要获取ind的值,方法:
$("#name").attr("ind")
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)