开发者

Not work append(jQuery) in the code

开发者 https://www.devze.com 2023-04-05 14:25 出处:网络
I use codeigniter but my JS code isn\'t working! Can anyone guide me? Example <select name=\"tour_name\" style=\"display: none; \">

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 () {
        $('#t开发者_StackOverflow中文版our_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 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

0

精彩评论

暂无评论...
验证码 换一张
取 消