2011-10-25 26 views
1

以下jQuery代碼不起作用。請檢查演示模糊事件引起的問題用文本框交換textarea,反之亦然

//code to change textbox 
$('.SpeakMindInputArea').live("click",function(){ 
    $(this).hide().next().show(5).focus(); 
    $(this).next().find('textarea').first().focus(); 

}); 
$('.SpeakMindField').live("blur",function(){ 
    $(this).find('.SpeakMindInputArea').first().show().next().hide();   
}); 

演示:http://jsfiddle.net/CwZKq/

我想在文本框的點擊它來改變textarea的和模糊到護牆後面。但如果我嘗試提交表單,則需要保持原樣。

+0

重新發布問題不是一個好主意。 – Bakudan

回答

1

也許你正在尋找somethign像這樣:http://jsfiddle.net/CwZKq/11/

//code to change textbox 
$('.SpeakMindInputArea input').live("focus",function(){ 
    $(this).parent().hide().next().show().find('textarea').focus(); 
}); 

$('.SpeakMindTextArea textarea').live("blur",function(){ 
    if ($(this).val() == '') 
     $(this).parent().hide().prev().show(); 
}); 

更新:現在它處理的提交:http://jsfiddle.net/CwZKq/13/

//code to change textbox 
$('.SpeakMindInputArea input').live("focus",function(){ 
    $('.SpeakMindTextArea textarea:visible').parent().hide().prev().show();   
    $(this).parent().hide().next().show().find('textarea').focus(); 
}); 
+0

謝謝,但在這種情況下,即使我嘗試提交表單模糊事件被解僱 – aWebDeveloper

+0

檢查我添加回答的第二個smaple。 – Samich

+0

怎麼樣模糊事件 – aWebDeveloper

1

你可以嘗試這樣的事:

$('.SpeakMindInputArea').live("focus",function(){ 
     $('.SpeakMindTextArea').not(this).hide().prev().show(); 
     $(this).hide().next().show().find('textarea').focus(); 
    }); 

在這種情況下,如果顯示一個textarea,只有在單擊另一個文本框時纔會隱藏它。

+0

可以你一次在我的小提琴運行ur代碼 – aWebDeveloper

+0

這裏是一個jsfiddle鏈接http://jsfiddle.net/CwZKq/ –

+0

謝謝安迪爾代碼不工作我在Linux上的chrome – aWebDeveloper