I am creating a div where I can populate different content based on a select value. It works that when I select an option, it loads. What I don't know how to do is load the first option when the pages first loads. I also am having an issue with jQuery scripts called in my header not applying to the ajax content when it loads. I'm hoping that by loading the first instance on page load, that will take care of the problem.
Here is my code:
<select class="post-link">
<option value="http://example.com">Option 1</option>
<option value="http://example.com">Option 2</option>
<option value="http://example.com">Option 3</option>
</select>
// This is where the content will be loaded
<div id="single-post-container"></div>
jQuery(document).ready(function($){
$.ajaxSetup({cache:false});
$(".post-link").change(function(){
var post_link = $(this).val();
$("#single-post-container").html("content loading");
$("#single-post-container").load(post_link);
return false;
});
});
Any direction would be appreciated!