【问题标题】:Not work append(jQuery) in the code代码中的附加(jQuery)不起作用
【发布时间】:2011-09-15 10:33:59
【问题描述】:

我使用 codeigniter,但我的 JS 代码不起作用!谁能指导我?

Example

<select name="tour_name" style="display: none; ">
    <option disabled="disabled" value="">select</option>
    <option>hello</option>
    <option>hi</option>
    <option>what</option>
    <option>how</option>
</select>
<div id="#tour_name">

JS:

$(document).ready(function () {
    $('select[name="tour_name"]').change(function () {
        $('#tour_name').empty();
        var $val = $(this).val();
        $(this).hide();
        $('#tour_name').hide().fadeIn('slow').append('<b>' + $val + '</b>')
        $('#tour_name b').click(function () {
            $('#tour_name').empty();
            $('select[name="tour_name"]').fadeIn('slow')();
        })
    })
});

【问题讨论】:

    标签: javascript jquery codeigniter caching


    【解决方案1】:

    您的 HTML 不正确。替换

    <div id="#tour_name">
    

    通过

    <div id="tour_name">
    

    【讨论】:

      【解决方案2】:

      改变

      <div id="#tour_name"> 
      

      <div id="tour_name">
      

      当为 element 创建一个 id 时。考虑这些事情

      为一个元素指定一个唯一的 id。

      命名规则:

      Must begin with a letter A-Z or a-z
      Can be followed by: letters (A-Za-z), digits (0-9), hyphens ("-"),
      

      和下划线(“_”) 在 HTML 中,所有值都不区分大小写

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-10-28
        • 2015-11-17
        • 1970-01-01
        • 2013-01-06
        • 2014-08-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多