簡體   English   中英

jQuery下拉更改值

[英]Jquery drop down changing value

我是jquery的大三學生,所以不能成為serios。 我想做一個簡單的腳本,將下拉列表值加1。 我通過此鏈接嘗試了許多方法: 在只讀文本輸入字段的jQuery值中添加+1,但這無濟於事。這就是我的腳本。

$('#nextPage').click(function () {
var page = $('#page').val();
$('#page').val(page + 1);
$('#search').submit();

});

HTML

<form id="search" method="POST" class="ui small form sixteen wide column segment">

<div class="three wide field">
    <label>Page number</label>
    <div class="ui selection dropdown" id="dropdown-pages">
        <input type="hidden" name="page" id="page" value="{{ filters.page }}">
        <div class="default text">Limit</div>
        <i class="dropdown icon"></i>
        <div class="menu">
            {% for page in 1..count_pages %}              
                <div class="item" data-value="{{ page }}">{{ page }}</div>
            {% endfor %}
        </div>
    </div>
</div>
<div class="two wide field">
    <label>By one</label>
    {% if filters.page != 1 %}
        <button class="ui submit button"><</button>
    {% endif %}
    {% if filters.page != count_pages %}
        <button class="ui submit button" id='nextPage'>></button>
    {% endif %}
</div>

搜索

明確

在此處輸入圖片說明

您可以通過以下方式獲得下拉頁面的價值:

var page = parseInt($('#dropdown-pages').val())+1;
alert(page);
var page = parseInt($('#page').val());
$('#page').val(page + 1);
$('#search').submit();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM