2011-09-15 62 views
2

我使用codeigniter但我的JS代码不工作!任何人都可以引导我?不工作追加(jQuery)的代码

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

回答

5

你的HTML不正确。 creatig一个ID元件时更换

<div id="#tour_name"> 

通过

<div id="tour_name"> 
+0

哦,这是正确的。这是我的错。 –

5

变化

<div id="#tour_name"> 

<div id="tour_name"> 

。考虑这些东西

指定元素的唯一ID。

命名规则:

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

和下划线( “_”) 在HTML中,所有值是不区分大小写