不工作追加(jQuery)在代码中



我使用codeigniter,但我的JS代码不工作!有人能指点我吗?

<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')();
        })
    })
});

您的HTML不正确。替换

<div id="#tour_name">

<div id="tour_name">

change

<div id="#tour_name"> 

<div id="tour_name">

为元素创建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中,所有值都是不区分大小写的

最新更新