表内的按钮调用javascript?

时间:2014-03-10 08:58:09

标签: javascript jquery zooming

<html>
<apex:includeScript value="//cdn.jsdelivr.net/jquery/1.7/jquery.min.js"/>          
<table width="100%">
             <tr>
             <td width="84%">      
             <apex:form id="form1" >
            <table bgcolor="#00C4FF" style="position:fixed;" width="100%" height="80">
             <tr>
             <td >
                   <b style="color:white;"> From :</b>
                    </td>
            <td>
                      <apex:selectList value="{!operator}" size="1" id="operator"  styleClass="input">
                        <apex:selectOption itemValue="=" itemLabel="Equal" />
                        <apex:selectOption itemValue="!=" itemLabel="Not Equal To"/>
                        <apex:selectOption itemValue="<=" itemLabel="Less Or Equal"/>
                        <apex:selectOption itemValue=">=" itemLabel="Greater Or Equal"/>
                        <apex:selectOption itemValue=">" itemLabel="Greater Than"/>
                        <apex:selectOption itemValue="<" itemLabel="Less Than"/>
                        <apex:selectOption itemValue="Like" itemLabel="Like"/>
                    </apex:selectList>
                    </td>
                    <td>              <apex:inputText value="{!inputText1}" id="autocomplete1"  styleClass="input"/>
            </td>
            <td>
                    <apex:commandButton value="Default View" action="{!showlist}" styleClass="input"/>
                    </td><td></td></tr></table><br/><br/><br/> 
                    </apex:form></td><td style="padding-top:173px;">
                    <button id="plusBtn" width="20px">+</button>
                    <button id="minusBtn" width="20px">-</button></td></tr></table>
    </html>

//当表格内的按钮不能正常工作时。当表格外的按钮正在调用javascript时,它不会调用javascript。工作正常         

     <button id="plusBtn" width="20px">+</button>
                <button id="minusBtn" width="20px">-</button>

Java script:

    <script type="text/javascript">
            $(document).ready(function(){
            var currFFZoom = 1;
            var currIEZoom = 100;
            var  button1 = document.getElementById("plusBtn");
    $(button1).on('click',function(){
        if ($.browser.mozilla){
            var step = 0.02;
            currFFZoom += step; 
            $("[id$=tblQuotes]").css('-moz-transform', 'scale(' + currFFZoom + ')');
        } else {
            var step = 2;
            currIEZoom += step;
            $("[id$=tblQuotes]").css('zoom', currIEZoom + '%');
        }
    });

    $('#minusBtn').on('click',function(){
        if ($.browser.mozilla){
            var step = 0.02;
            currFFZoom -= step;                 
            $("[id$=tblQuotes]").css('-moz-transform', 'scale(' + currFFZoom + ')');

        } else {
            var step = 2;
            currIEZoom -= step;
            $("[id$=tblQuotes]").css('zoom', currIEZoom + '%');
        }
    });
            });
    </script>

当表中的按钮不能正常工作时。当表调用javascript时,表中的按钮不会调用javascript。它工作正常

1 个答案:

答案 0 :(得分:0)

最好的我可以不看HTML:

更改

    var  button1 = document.getElementById("plusBtn");
$(button1).on('click',function(){

    var  button1 = $("#plusBtn");
button1.click(function(){