使用它的id和class唯一标识和元素

时间:2013-06-06 13:20:35

标签: jquery jquery-ui-spinner

我在html页面上有6个jquery ui微调器。当我通过单击微调按钮(向上或向下)更改第一个微调器的值时,我想要隐藏图像。

当键盘更改第一个微调器的值时隐藏图像,但是当我通过微调器按钮更改图像时,图像不会隐藏。

这是输入文本,它变成了微调器

<input type="text" class="save_check controller_performance" id="txtCtrlr" name="txtCtrlr" value="0" style="width: 50px; border-style: none;" />

这是它变成微调器(从萤火虫复制)时的结构

<div class="ui-spinner">
<input type="text" style="width: 50px; border-style: none;" value="0" name="txtCtrlr" id="txtCtrlr" class="save_check controller_performance ui-spinner-box" autocomplete="off">
<button type="button" class="ui-spinner-up">▲</button><button type="button" class="ui-spinner-down">▼</button></div>

和微调按钮我正在为

编写代码
$(".ui-spinner-up").click(function (){
    console.log("in click function");
    var parentClass = $(this).parent().attr("class");
    $(this).siblings(".controller_performance").change(hideControllerPerformanceInfo);
    console.log("class is " + parentClass);
       $(parentClass).siblings(".controller_performance").change(function(){
        console.log("changing siblings");
        });
    var id = $('.'+ parentClass+ ':input').attr('id');
    console.log("id is --> " + id);
    if($(this).attr("id") == "txtCtrlr") {
         // hideControllerPerformanceInfo();
         $(".ui-spinner-box").bind("propertychange keyup input paste", hideControllerPerformanceInfo );
    }
});

是否有其他方法可以唯一标识第一个微调器并调用隐藏功能。我不能基于类作为选择器编写jquery代码,它将应用于所有微调器。

0 个答案:

没有答案
相关问题