开发者

Ajax: Load page content to div with select box

开发者 https://www.devze.com 2022-12-20 20:28 出处:网络
I\'m trying to load page content into a div via Aja开发者_StackOverflow中文版x when a select option is selected

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

精彩评论

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

关注公众号