开发者

Ajax: Load page content to div with select box

I'm trying to load page content into a div via Aja开发者_StackOverflow中文版x when a select option is selected

eg. I have a select box with 2 options the values are test.HTML and test1.HTML and under that I have a div and want the content from test.HTML and test1.HTML to load in the div when the select box changes... Via Ajax any suggestions?

Thanks


Sure, that can be rather simple:

$("#mySelect").change(function(){
  $("#myDiv").load( $(this).val() );
});
<select id="mySelect">
  <option>test.html</option>
  <option>test1.html</option>
</select>

<div id="myDiv"></div>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜