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
精彩评论