Q:

jquery function to replace a div on click

I have created a function which on-click hides the first child of the div and and replaces it with another... now the query is on-click alert(divno) which should be returning 2 if the divno was 1 but it is returning 11
$('#rightarrow').click(function(){
    var getdivname = $('#dcontainer').find("div").first();
    var divid = getdivname.attr("id");
    var divno = divid.match(/[0-9]+/);
    $('#d'+divno).hide();
    divno=divno+1;
    $('#d'+divno).appendTo('#dcontainer');
     alert(divno);
});

if I,m using parseInt(divid, 10) it is returning NaN

A:

Simply use a Unary + to convert the value of divno to an integer rather than string:
divno=+divno+1;

The unary plus operator precedes its operand and evaluates to its operand but attempts to converts it into a number, if it isn't already. For example, y = +x takes the value of x and assigns that to y; that is, if x were 3, y would get the value 3 and x would retain the value 3; but if x were the string "3", y would also get the value 3. 

We can prove this by attempting the following tests:
"1" + 1     // "11"
+"1" + 1    // 2

