hi, i have multiple looped button elements. if a user clicked any button, a div tag below the button need to open, i tried some thing like below. first button works correctly.but other buttons don't work.
here is my complete codes.
<?php
/*
Plugin Name: My test plugin
Description: some description.
*/
add_action('admin_enqueue_scripts','my_scripts');
function my_scripts(){
wp_enqueue_script('openjs',plugins_url('/some-js.js',__FILE__));
wp_enqueue_style('my-css',plugins_url('/some-css.css',__FILE__));
}
function add_admins() {
add_menu_page('my page', 'my title', 'administrator', 'my-page-slug', 'admin_views');
}
function admin_views() {
$arrays = array(
'one' => 'some val one',
'two' => 'some val two',
'three' => 'some val three'
);
foreach($arrays as $k => $v){
?>
<div id="container">
<input type="button" id="open_div" value="open" />
<div id="div_hidden">
<h2>Some title</h2>
<div><?php echo $v; ?></div>
</div>
</div>
<?php
}
}
?>
my css file some-css.css
#div_hidden{
display:none;
}
my javascript file some-js.js
jQuery(document).ready(function($){
$('#open_div').click(function() {
$(this).next('#div_hidden').slideToggle('slow');
});
});
Any body help me to fix this problem?