读书人

超级简单的有关问题初学者

发布时间: 2013-12-13 00:50:19 作者: rapoo

超级简单的问题,菜鸟求救
关于href传参的,要传递的值是某个input的value,比如说<input type="hidden" name="yhbh" value="">
href比如为<a href="?aa="></a>,吧input的 value放到href中,如何实现

或许你就将$("#hidden1").val()跟在你要跳转的URL后面
[解决办法]

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0">
<title>test</title>
<script type="text/javascript" src="js/app.js"></script>
</head>
<style type="text/css">

</style>
<body>

<input type="text" value="test" class="txt" />

<a href="http://www.test.com" title="" class="link">click</a>


<script type="text/javascript">
$(function(){

var val = $(".txt").val(),href = $(".link").attr("href");
$(".link").attr("href",href +"?aa="+ val);



})

</script>


</body>
</html>

[解决办法]
<form action=''>
<input type="hidden" name="yhbh" value="kk">
<input type='submit' >
</form>

读书人网 >CSS

热点推荐