[Solved] how to get value outside jquery click function

the second alert(projectId); outside the “click” event handler runs as soon as the page loads. Inevitably this is before your “click” handler can possibly be executed, because the user has likely not had time to click on it, and even if they had time, there’s no guarantee that they will. Therefore the variable projectId is … Read more

[Solved] Insert HTML dynamically based on CSS class with Javascript

What about ? <body class=”en”> <script> if($(‘body’).hasClass(‘de’)) { $(‘body’).html(‘<div id=”de”>some html</div>’); } else if($(‘body’).hasClass(‘en’)) { $(‘body’).html(‘<div id=”en”>some other html</div>’); } else if($(‘body’).hasClass(‘es’)) { $(‘body’).html(‘<div id=”es”>another html</div>’); } else { … } </script> Dynamic : var bodyClass = $(‘body’).attr(“class”); var bodyValue = $(‘#’ + bodyClass).html(); $(‘body’).html(bodyValue); But you should verify that body has a class and … Read more

[Solved] Is there a way to get the value of {{org}} from this? [duplicate]

Without the quotes, nameOrg is an invalid JavaScript variable. $(nameOrg) Here’s the right way to select an element by it’s ID: $(‘#nameOrg’) Reference: https://api.jquery.com/id-selector/ Also, I see your html document does not contain any reference of jQuery. Make sure you are importing the library. <script src=”https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js”></script> I strongly suggest wrapping the code in a jQuery … Read more

[Solved] if window.location.href.indexOf(‘player=1’) add style [closed]

You need to set the style of the body element if the string you are checking for is present in the URL. if(window.location.href.indexOf(“player=1″)!=-1) document.body.style.backgroundColor=”#000”; Alternatively, to avoid setting inline styles, you can create a new class and apply it to the body if the string you are checking for is present. body.player1{ background:#000; } if(window.location.href.indexOf(“player=1”)!=-1) … Read more

[Solved] Detect Specific Words on string

Check this out, i add comment for easy understand this code var str=”@hello, world how are you. I @am good”; str = str.split(‘ ‘); // split text to word array str = str.filter(function(word){ return word.includes(‘@’); // check words that using @ }).map(function (word) { return word.replace(/[^a-zA-Z^@ ]/g, “”) // remove special character except @ }); … Read more

[Solved] How to write the for loop in javascript [closed]

$.each() doesn’t return what the callback function does, you need to use $.map, then .join() to combine all the results back into a string. But a simpler way is to take the loop out of the concatenation, and instead append to the string in the loop. var htmlString = ‘<section class=”content-header”><h1>Employee</h1></section><!– Main content –><section class=”content”><div … Read more

[Solved] Uncaught TypeError: Not a function

You must include the JS file where the Slider function is defined. Maybe jQuery Slider, from jQueryUI? <link rel=”stylesheet” href=”https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css”> <script src=”https://code.jquery.com/jquery-1.10.2.js”></script> <script src=”https://code.jquery.com/ui/1.11.4/jquery-ui.js”></script> <link rel=”stylesheet” href=”http://stackoverflow.com/resources/demos/style.css”> Here is the working demo. 12 solved Uncaught TypeError: Not a function

[Solved] Jquery with while loop error [closed]

Try using a function that returns an array instead, and do a loop inside there. $(‘#calendar’).fullCalendar({ editable: true, events: function(){ var arr = []; for(var i = 0; i <= 10; i++){ arr.push({ title: ‘All Day Event’, start: new Date(y,m,i) }); } return arr; }() // <– Here we execute the function, so it evaluates … Read more

[Solved] How to change font size inside option of a select box if it has number?

Yo cant individually style elements in options. This element is rendered by the OS, not HTML. It cannot be styled via CSS. There are replacement plug-ins that look like a SELECT, but are actually composed from regular HTML elements that CAN be styled. Use instead https://github.com/HubSpot/select or https://select2.org/ solved How to change font size inside … Read more

[Solved] Allowing user to customize the items on the list menubar

What you’re looking for is possible with vanilla Javascript, jQuery, or a host of other libraries. jQuery is where I’d recommend you start. You can create new elements by passing html elements as strings to the jQuery function. See the “Creating New Elements” section of this page. Using append and remove as Muzammil mentioned, you … Read more

[Solved] Why isn’t my image doing a parallax scroll?

You do get your scrolltop in the console like that, on codepen, but likely not on local. Learn about $(document).ready(function(){ Always load the jQuery src first, after the body element, then the rest of the JS code. Or inline it after the body closing tag. But always the jQuery first. Then , depending on the … Read more