I have this jquery code to check for any value on a given input and then add a simple class if the input has a value.
But in console i receive error that .val() is not a function?
my code is:
$.fn.tkFormControlMaterial = function(){
this
.blur(function () {
if (this.val())
this.addClass('used');
else
this.removeClass('used');
})
.after('<span class="ma-form-highlight"></span><span class="ma-form-bar"></span>');
};
bind will set you free
$.fn.tkFormControlMaterial = function(){
this
.blur(function () {
if (this.val())
this.addClass('used');
else
this.removeClass('used');
}.bind(this))
.after('<span class="ma-form-highlight"></span><span class="ma-form-bar"></span>');
}.bind(this);
I found the solution.
If anyone needs a working sample of my own code above:
$.fn.tkFormControlMaterial = function(){
$(this)
.blur(function () {
if ($(this).val())
$(this).addClass('used');
else
$(this).removeClass('used');
})
.after('<span class="ma-form-highlight"></span><span class="ma-form-bar"></span>');
};
I am having a bit of trouble getting momentjs to convert a date to unix in the correct way: var start = new Date(2013,11,2); console.log('Start date: '+start); console.log('Unix date: '+moment(start)....
I am having a bit of trouble getting momentjs to convert a date to unix in the correct way: var start = new Date(2013,11,2); console.log('Start date: '+start); console.log('Unix date: '+moment(start)....
I am wondering if there is some better way to communicate between distant components. In my case I have structure like this: <div> <History /> <Board> <BoxesView> ...
I am wondering if there is some better way to communicate between distant components. In my case I have structure like this: <div> <History /> <Board> <BoxesView> ...
-- Hi ! Reader, if you are not comfortable with Tumblr, please tell me, I will give more details! I had some issues on my tumblr page with the default theme 'Optica'. When I post an embed SoundCloud ...
-- Hi ! Reader, if you are not comfortable with Tumblr, please tell me, I will give more details! I had some issues on my tumblr page with the default theme 'Optica'. When I post an embed SoundCloud ...
I would like to dynamically remove or disable a <style> tag that looks like this <style type="text/css" id="cssx/portal/simple-sidebar.css" designtr="cssx/portal/simple-sidebar.css"> #...
I would like to dynamically remove or disable a <style> tag that looks like this <style type="text/css" id="cssx/portal/simple-sidebar.css" designtr="cssx/portal/simple-sidebar.css"> #...