简体   繁体   中英

Not work append(jQuery) in the code

I use codeigniter but my JS code isn't working! Can anyone guide me?

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

Your HTML is incorrect. Replace

<div id="#tour_name">

by

<div id="tour_name">

change

<div id="#tour_name"> 

to

<div id="tour_name">

when creatig an id to element . consider these things

Specifies a unique id for an element.

Naming rules:

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

and underscores ("_") In HTML, all values are case-insensitive

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM