Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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')();
        })
    })
});
like image 212
Jennifer Anthony Avatar asked May 13 '26 22:05

Jennifer Anthony


2 Answers

Your HTML is incorrect. Replace

<div id="#tour_name">

by

<div id="tour_name">
like image 65
Niko Avatar answered May 15 '26 12:05

Niko


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 A-Z or a-z
Can be followed by: letters (A-Za-z), digits (0-9), hyphens ("-"),

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

like image 42
Kanishka Panamaldeniya Avatar answered May 15 '26 10:05

Kanishka Panamaldeniya



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!