I have three divs and one button. In to my jQuery script, everytime I click on button, those three divs elements refreshed at once.
HTML Code
<input id="refresh" type="button" value="Refresh"/>
<div id="R1">Value 1</div>
<div id="R2">Value 2</div>
<div id="R3">Value 3</div>
JQUERY CODE
var $JQ_ = jQuery.noConflict();
$JQ_(document).ready(function () {
$JQ_("#refresh").click(function () {
$JQ_("#R1").load("index.php#R1").fadeOut(1000).fadeIn(1000);
});
$JQ_("#refresh").click(function () {
$JQ_("#R2").load("index.php #R2").fadeOut(1000).fadeIn(1000);
});
$JQ_("#refresh").click(function () {
$JQ_("#R3").load("index.php #R3").fadeOut(1000).fadeIn(1000);
});
});
JSFIDDLE Example here.
What I want to do is to make my code shorter and not to have to write the same thing for all my divs. In to an other script I am using something like this
$JQ_("[id^='opener_']").click(function () {
$JQ_("#dialog_" + this.id.split('_')[1]).dialog("open");
});
but this is an other case. Any idea how can I make my code work like this?