I am creating a simple function which shows a login button when both inputs are not empty, however, jQuery does not seem to want to allow me.
I have checked to make sure the jQuery API that I am using is up to date and correct, but nothing seems to be out of the ordinary.
jQuery:
$(document).ready(function(){
var u = $.trim($("#_jq-loC1").val());
var p = $.trim($('#_jq-loC2').val());
var l = $('#_jq-slO1');
if(u.length > 0 && p.length > 0) {
l.addClass('slO1');
} else {
l.removeClass('slO1');
}
});
HTML:
<input type="text" name="username" id="_jq-loC1" placeholder="Username" autocomplete="off">
<input type="password" name="password" id="_jq-loC2" placeholder="Password" autocomplete="off">
<input style="width: 0.1px; height:0.1px; opacity: 0; overflow: hidden;" id="login" type="submit" value="">
<div class="send-login-container">
<label class="send-login" id="_jq-slO1" for="login"></label>
</div>
CSS:
.slO1{
width: 54px;
}
Cheers.
$(l).addClass('slO1');