0

I am not adding it through a separate vf resource even.

I am directly writing HTML on the page.

<script>
$.noConflict();
(function($){
    function floatLabel(inputType){
        $(inputType).each(function(){
            console.log("jQ Running");
            var $this = $(this);
            // on focus add cladd active to label
            $this.focus(function(){
                $this.next().addClass("active");
                console.log("jQ active added");
            });
            //on blur check field and remove class if needed
            $this.blur(function(){
                if($this.val() === '' || $this.val() === 'blank'){
                    $this.next().removeClass();
                    console.log("jQ active removed");
                }
            });
        });
    }
    // just add a class of "floatLabel to the input field!"
    floatLabel(".floatLabel");
})(jQuery);
</script>

it does not work at all.

anyone know why?

1
  • 1
    Have you examined your browser console for errors?
    – Adrian Larson
    Feb 22 '17 at 2:13
-3

solved it.

it was pretty basic.

but now works. thanks guys. and it never even loaded by console values.

thanks.

<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js" />
<script>
var j$ = jQuery.noConflict();
j$(document).ready(function(j$){
    function floatLabel(inputType){
        j$(inputType).each(function(){
            console.log("jQ Running");
            var j$this = j$(this);
            // on focus add cladd active to label
            j$(this).focus(function(){
                j$(this).next().addClass("active");
                console.log("jQ added active class");
            });
            //on blur check field and remove class if needed
            j$(this).blur(function(){
                if(j$(this).val() === '' || j$(this).val() === 'blank'){
                    j$(this).next().removeClass();
                    console.log("jQ removed active class");
                }
            });
        });
    }
    // just add a class of "floatLabel to the input field!"
    floatLabel(".floatLabel");
})(jQuery);
</script>
2
  • Please add some text explaining what you actually fixed and why it didn't work.
    – Adrian Larson
    Feb 22 '17 at 2:24
  • Please edit your post to be more clear...that's not what comments are for.
    – Adrian Larson
    Feb 22 '17 at 2:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.