get value from function inside function jquery [duplicate]





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0
















This question already has an answer here:




  • How do I return the response from an asynchronous call?

    33 answers




I'm really stuck with getting a value from this function, my guess is that it is because of the functions inside the functions.



(ps. I know I don't have to use quotes when I want to get a BOOL value)



Please help



$(document).ready(function() {    
var text = null;

function textCheck() {
if ($('.window-' + sc).has('input[type="text"]')) {
$(this).find('input[type="text"]').each(function() {
$(this).on('click', function() {
if ($(this).attr('required')) {
var placeholder = $(this).attr('original');

if (!$(this).val() == '') {
$(this).removeClass('is-invalid shake').addClass('is-valid').attr('placeholder', placeholder);
text = 'true';
//return text;
} else {
$(this).addClass('is-invalid shake').attr('placeholder', placeholder + " can't be empty");
text = 'false';
//return text;
};
};

});
});
};
return text;
};

var texxt = textCheck();
console.log(texxt);
});









share|improve this question















marked as duplicate by Quentin javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 22 '18 at 0:33


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 1





    Logic is flawed. The value of text gets assigned after user clicks on an <input>. You can't access it until that occurs.

    – charlietfl
    Nov 22 '18 at 0:25













  • The "$(this).on('click', function() {" is getting in your way. This looks like a validation function, but you are binding an event handler which won't fire till the user clicks something. Try removing the binding and see if that helps.

    – Sage
    Nov 22 '18 at 0:26











  • even if i comment out the click function i still get 'undefined' response..

    – RMCS
    Nov 22 '18 at 15:46


















0
















This question already has an answer here:




  • How do I return the response from an asynchronous call?

    33 answers




I'm really stuck with getting a value from this function, my guess is that it is because of the functions inside the functions.



(ps. I know I don't have to use quotes when I want to get a BOOL value)



Please help



$(document).ready(function() {    
var text = null;

function textCheck() {
if ($('.window-' + sc).has('input[type="text"]')) {
$(this).find('input[type="text"]').each(function() {
$(this).on('click', function() {
if ($(this).attr('required')) {
var placeholder = $(this).attr('original');

if (!$(this).val() == '') {
$(this).removeClass('is-invalid shake').addClass('is-valid').attr('placeholder', placeholder);
text = 'true';
//return text;
} else {
$(this).addClass('is-invalid shake').attr('placeholder', placeholder + " can't be empty");
text = 'false';
//return text;
};
};

});
});
};
return text;
};

var texxt = textCheck();
console.log(texxt);
});









share|improve this question















marked as duplicate by Quentin javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 22 '18 at 0:33


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 1





    Logic is flawed. The value of text gets assigned after user clicks on an <input>. You can't access it until that occurs.

    – charlietfl
    Nov 22 '18 at 0:25













  • The "$(this).on('click', function() {" is getting in your way. This looks like a validation function, but you are binding an event handler which won't fire till the user clicks something. Try removing the binding and see if that helps.

    – Sage
    Nov 22 '18 at 0:26











  • even if i comment out the click function i still get 'undefined' response..

    – RMCS
    Nov 22 '18 at 15:46














0












0








0









This question already has an answer here:




  • How do I return the response from an asynchronous call?

    33 answers




I'm really stuck with getting a value from this function, my guess is that it is because of the functions inside the functions.



(ps. I know I don't have to use quotes when I want to get a BOOL value)



Please help



$(document).ready(function() {    
var text = null;

function textCheck() {
if ($('.window-' + sc).has('input[type="text"]')) {
$(this).find('input[type="text"]').each(function() {
$(this).on('click', function() {
if ($(this).attr('required')) {
var placeholder = $(this).attr('original');

if (!$(this).val() == '') {
$(this).removeClass('is-invalid shake').addClass('is-valid').attr('placeholder', placeholder);
text = 'true';
//return text;
} else {
$(this).addClass('is-invalid shake').attr('placeholder', placeholder + " can't be empty");
text = 'false';
//return text;
};
};

});
});
};
return text;
};

var texxt = textCheck();
console.log(texxt);
});









share|improve this question

















This question already has an answer here:




  • How do I return the response from an asynchronous call?

    33 answers




I'm really stuck with getting a value from this function, my guess is that it is because of the functions inside the functions.



(ps. I know I don't have to use quotes when I want to get a BOOL value)



Please help



$(document).ready(function() {    
var text = null;

function textCheck() {
if ($('.window-' + sc).has('input[type="text"]')) {
$(this).find('input[type="text"]').each(function() {
$(this).on('click', function() {
if ($(this).attr('required')) {
var placeholder = $(this).attr('original');

if (!$(this).val() == '') {
$(this).removeClass('is-invalid shake').addClass('is-valid').attr('placeholder', placeholder);
text = 'true';
//return text;
} else {
$(this).addClass('is-invalid shake').attr('placeholder', placeholder + " can't be empty");
text = 'false';
//return text;
};
};

});
});
};
return text;
};

var texxt = textCheck();
console.log(texxt);
});




This question already has an answer here:




  • How do I return the response from an asynchronous call?

    33 answers








javascript jquery function return






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '18 at 2:09









A J

5572721




5572721










asked Nov 22 '18 at 0:19









RMCSRMCS

608




608




marked as duplicate by Quentin javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 22 '18 at 0:33


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Quentin javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 22 '18 at 0:33


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 1





    Logic is flawed. The value of text gets assigned after user clicks on an <input>. You can't access it until that occurs.

    – charlietfl
    Nov 22 '18 at 0:25













  • The "$(this).on('click', function() {" is getting in your way. This looks like a validation function, but you are binding an event handler which won't fire till the user clicks something. Try removing the binding and see if that helps.

    – Sage
    Nov 22 '18 at 0:26











  • even if i comment out the click function i still get 'undefined' response..

    – RMCS
    Nov 22 '18 at 15:46














  • 1





    Logic is flawed. The value of text gets assigned after user clicks on an <input>. You can't access it until that occurs.

    – charlietfl
    Nov 22 '18 at 0:25













  • The "$(this).on('click', function() {" is getting in your way. This looks like a validation function, but you are binding an event handler which won't fire till the user clicks something. Try removing the binding and see if that helps.

    – Sage
    Nov 22 '18 at 0:26











  • even if i comment out the click function i still get 'undefined' response..

    – RMCS
    Nov 22 '18 at 15:46








1




1





Logic is flawed. The value of text gets assigned after user clicks on an <input>. You can't access it until that occurs.

– charlietfl
Nov 22 '18 at 0:25







Logic is flawed. The value of text gets assigned after user clicks on an <input>. You can't access it until that occurs.

– charlietfl
Nov 22 '18 at 0:25















The "$(this).on('click', function() {" is getting in your way. This looks like a validation function, but you are binding an event handler which won't fire till the user clicks something. Try removing the binding and see if that helps.

– Sage
Nov 22 '18 at 0:26





The "$(this).on('click', function() {" is getting in your way. This looks like a validation function, but you are binding an event handler which won't fire till the user clicks something. Try removing the binding and see if that helps.

– Sage
Nov 22 '18 at 0:26













even if i comment out the click function i still get 'undefined' response..

– RMCS
Nov 22 '18 at 15:46





even if i comment out the click function i still get 'undefined' response..

– RMCS
Nov 22 '18 at 15:46












1 Answer
1






active

oldest

votes


















1














in you textCheck() function ,the first $(this) stands for window

change this to your element






share|improve this answer






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    in you textCheck() function ,the first $(this) stands for window

    change this to your element






    share|improve this answer




























      1














      in you textCheck() function ,the first $(this) stands for window

      change this to your element






      share|improve this answer


























        1












        1








        1







        in you textCheck() function ,the first $(this) stands for window

        change this to your element






        share|improve this answer













        in you textCheck() function ,the first $(this) stands for window

        change this to your element







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 '18 at 0:31









        Abdulsattar AlkhalafAbdulsattar Alkhalaf

        33216




        33216

















            Popular posts from this blog

            鏡平學校

            ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

            Why https connections are so slow when debugging (stepping over) in Java?