1
if($(currentTab+' form.dataform').attr('name') !== undefined)
    var $selectedTab = $(currentTab+' form.dataform').attr('name');
else  
var selectedTab = '0';

alert($(selectedTab)); Gives me an object. I need string. How?

1 Answer 1

1

Drop the $() around the selectedTab, and remove the $ from the variable definition.

if($(currentTab+' form.dataform').attr('name') !== undefined)
    var selectedTab = $(currentTab+' form.dataform').attr('name');
else  
    var selectedTab = '0';

alert(selectedTab);
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, and one more thing: var $selectedTab >> var selectedTab
I actually did say that, but not clearly. I'll edit to improve clarity.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.