While i only have a minute to help, i can point out quickly that
var divs = document.getElementsByTagName('DIV');
var divCounter = 1;
for(var no=0;no<divs.length;no++){
if(divs[no].className=='breakbg'){
divs[no].onclick = showHideContent;
divs[no].id = 'ssdm'+divCounter;
...........
}
}
Can be
$("div.breakbg").each(function(i) {
var $div = $(this).attr("id", "ssdm" + (i + 1)).click
(showHideContent);
// you can now use jQuery object $div to reference the rest
});
And keep in mind one thing like the reply above almost says: jQuery
*is* JavaScript... that seems to get over looked a lot
On Jan 13, 4:48 am, modestmj <[email protected]> wrote:
> Hello everyone...I'm really new to jQuery..I have an urgent requirement to
> convert this javascript to jQuery...So please...try to help me with this..
>
> function initShowHideDivs()
> {
> var divs = document.getElementsByTagName('DIV');
> var divCounter = 1;
> for(var no=0;no<divs.length;no++){
> if(divs[no].className=='breakbg'){
> divs[no].onclick = showHideContent;
> divs[no].id = 'ssdm'+divCounter;
> var answer = divs[no].nextSibling;
> while(answer && answer.tagName!='DIV'){
> answer = answer.nextSibling;
> }
> //divs[no].className=='ssdhead';
> answer.id = 'ssds'+divCounter;
> contentDiv = answer.getElementsByTagName('DIV')[0];
> contentDiv.style.top = 0 - contentDiv.offsetHeight +
> 'px';
> contentDiv.className='ssdcontent';
> contentDiv.id = 'ssdsc' + divCounter;
> answer.style.display='none';
> answer.style.height='1px';
> divCounter++;
> }
> }
>
> }
>
> function showHideContent(e,inputId)
> {
>
> if(yatrassd_slideInProgress)return;
> yatrassd_slideInProgress = true;
> if(!inputId)inputId = this.id;
> inputId = inputId + '';
> var numericId = inputId.replace(/[^0-9]/g,'');
> var answerDiv = document.getElementById('ssds' + numericId);
> var imgId = document.getElementById('arrowimg'+ numericId);
>
> objectIdToSlideDown = false;
>
> if(!answerDiv.style.display || answerDiv.style.display=='none'){
> imgId.src='/yatra_blue-theme/images/hotel/ssdarrowdown.gif';
> if(yatrassd_activeId && yatrassd_activeId!=numericId){
>
> objectIdToSlideDown = numericId;
>
> slideContent(yatrassd_activeId,(yatrassd_slideSpeed*-1));
>
> imgId.src='/yatra_blue-theme/images/hotel/ssdarrowup.gif';
> }else{
>
> answerDiv.style.display='block';
> answerDiv.style.visibility = 'visible';
>
> imgId.src='/yatra_blue-theme/images/hotel/ssdarrowup.gif';
> slideContent(numericId,yatrassd_slideSpeed);
> }
> }else{
> slideContent(numericId,(yatrassd_slideSpeed*-1));
> yatrassd_activeId = false;
> imgId.src='/yatra_blue-theme/images/hotel/ssdarrowdown.gif';
> }
>
> }
>
> --
> View this message in
> context:http://old.nabble.com/Converting-a-javascript-to-jQuery-tp27142142s27...
> Sent from the jQuery General Discussion mailing list archive at Nabble.com.