使用jquery怎么根据ID给元素赋值
3个回答
展开全部
方法/步骤
1
编写页面:
<input type="button" value="按价格" name="score" id="bypic" onclick="bypicord()">
<input type="hidden" value="desc" id="ordercon">
2
编写js:
<script type="text/javascript">
function bypicord(){
var reorder = $("#ordercon").val();
if("desc" == reorder){
$("#ordercon").val("asc");
var url = "<%=path
%>/product/listproduct.action?uid="+${sessionScope.user.id}+"&sort=price&ten=Y&FROMBUS=Y&order=asc";
gotoquery(url);
//window.location.href =gotoquery('url');
}else {
$("#ordercon").val("desc");
reorder = "desc";
var url = "<%=path
%>/product/listproduct.action?uid="+${sessionScope.user.id}+"&sort=price&ten=Y&FROMBUS=Y&order=desc";
gotoquery(url);
}
}
</script>
其中的:$("#ordercon").val("asc");就是给id为ordercon的元素赋值
3
效果如下:
END
注意事项
其中的:$("#ordercon").val("asc");就是给id为ordercon的元素赋值
http://jingyan.baidu.com/article/9989c746058347f648ecfed8.html
1
编写页面:
<input type="button" value="按价格" name="score" id="bypic" onclick="bypicord()">
<input type="hidden" value="desc" id="ordercon">
2
编写js:
<script type="text/javascript">
function bypicord(){
var reorder = $("#ordercon").val();
if("desc" == reorder){
$("#ordercon").val("asc");
var url = "<%=path
%>/product/listproduct.action?uid="+${sessionScope.user.id}+"&sort=price&ten=Y&FROMBUS=Y&order=asc";
gotoquery(url);
//window.location.href =gotoquery('url');
}else {
$("#ordercon").val("desc");
reorder = "desc";
var url = "<%=path
%>/product/listproduct.action?uid="+${sessionScope.user.id}+"&sort=price&ten=Y&FROMBUS=Y&order=desc";
gotoquery(url);
}
}
</script>
其中的:$("#ordercon").val("asc");就是给id为ordercon的元素赋值
3
效果如下:
END
注意事项
其中的:$("#ordercon").val("asc");就是给id为ordercon的元素赋值
http://jingyan.baidu.com/article/9989c746058347f648ecfed8.html
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2016-07-17 · 百度知道合伙人官方认证企业
育知同创教育
1【专注:Python+人工智能|Java大数据|HTML5培训】 2【免费提供名师直播课堂、公开课及视频教程】 3【地址:北京市昌平区三旗百汇物美大卖场2层,微信公众号:yuzhitc】
向TA提问
关注
展开全部
方法/步骤
编写页面:
<input type="button" value="按价格" name="score" id="bypic" onclick="bypicord()">
<input type="hidden" value="desc" id="ordercon">
编写js:
<script type="text/javascript">
function bypicord(){
var reorder = $("#ordercon").val();
if("desc" == reorder){
$("#ordercon").val("asc");
var url = "<%=path %>/product/listproduct.action?uid="+${sessionScope.user.id}+"&sort=price&ten=Y&FROMBUS=Y&order=asc";
gotoquery(url);
//window.location.href =gotoquery('url');
}else {
$("#ordercon").val("desc");
reorder = "desc";
var url = "<%=path %>/product/listproduct.action?uid="+${sessionScope.user.id}+"&sort=price&ten=Y&FROMBUS=Y&order=desc";
gotoquery(url);
}
}
</script>
其中的:$("#ordercon").val("asc");就是给id为ordercon的元素赋值
编写页面:
<input type="button" value="按价格" name="score" id="bypic" onclick="bypicord()">
<input type="hidden" value="desc" id="ordercon">
编写js:
<script type="text/javascript">
function bypicord(){
var reorder = $("#ordercon").val();
if("desc" == reorder){
$("#ordercon").val("asc");
var url = "<%=path %>/product/listproduct.action?uid="+${sessionScope.user.id}+"&sort=price&ten=Y&FROMBUS=Y&order=asc";
gotoquery(url);
//window.location.href =gotoquery('url');
}else {
$("#ordercon").val("desc");
reorder = "desc";
var url = "<%=path %>/product/listproduct.action?uid="+${sessionScope.user.id}+"&sort=price&ten=Y&FROMBUS=Y&order=desc";
gotoquery(url);
}
}
</script>
其中的:$("#ordercon").val("asc");就是给id为ordercon的元素赋值
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
比如$("#a").val("m")
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询