社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Jquery

无法从jquery文档调用函数

Community wiki • 2 年前 • 453 次点击  

我有一个功能,当用户点击按钮时,我会设置cookie值。

在change事件中,我从选择框中调用两个方法。这个函数调用正确,工作正常。但当我从下面的jquery函数调用这两个函数时,我遇到了问题。 <select NAME="the_menu" size="1" id="Item" onChange="UpdateUnitMenu(this, document.form_A.unit_menu); UpdateUnitMenu(this, document.form_B.unit_menu)"> 如果有任何cookie以“语言”的名义存在,我想调用相同的方法。 two函数基本上基于对第一个值的选择来填充另外两个下拉选择框值。

我的表单

 <form name="property_form" >
     <select NAME="the_menu" size="1" id="Item" onChange="UpdateUnitMenu(this, document.form_A.unit_menu); UpdateUnitMenu(this, document.form_B.unit_menu)">   <optgroup label="Select Any One Type">   </optgroup>  </select>
     <input type="button" id='continue' value="Save as default value"/>
 </form>

我的功能

<script>
        $(document).ready(function(){  
            $('#continue').click(function() {
                 var singleValues = $("#Item").val(); 
                $.cookie("language", singleValues); 
            })  
      alert($.cookie('language'));
      $('#Item').val($.cookie('language')).attr('selected', true);

      if($.cookie('language')!=null)
               {  
                 var th=$.cookie('language');
                 UpdateUnitMenu(th, document.form_A.unit_menu);//trying to call first function
                 UpdateUnitMenu(th, document.form_B.unit_menu);//trying to call first function
               } 
        });
    </script>   
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/154598
 
453 次点击  
文章 [ 1 ]  |  最新文章 2 年前