[Solved] javascript variable > than number

[ad_1] If your goal is to find all matching divs, you have to do a bit more work. Not a lot, but a bit: var w = 1600; var h = 1063; // Find all divs and filter them var matchingDivs = $(“div”).filter(function() { // Does this div’s text match the form (1601 x 1064)? … Read more

[Solved] Amend img src using jQuery [closed]

[ad_1] Check out this jsfiddle: <img src=”https://stackoverflow.com/uploads/lorem_m_1-375×349.png”> <img src=”/uploads/ipsum_m_1-248×378.png”> <img src=”/uploads/dolor_m_1-392×298.png”> $(‘img’).each(function() { var src = $(this).attr(‘src’); $(this).attr(‘src’,replaceNumbers(src)); //console.log($(this).attr(‘src’)); }); function replaceNumbers(str) { var regex = /-\d+x\d+/; return str.replace(regex,”); } replaceNumbers() simply takes a string (in this case, your image source) and replaces the ‘-00×00’ with empty string. Then, it returns that string, and in … Read more

[Solved] jQuery how to disable event handle

[ad_1] Remove hash from <li id=’#myElement’>. Correct syntax is : <li id=’myElement’> $(‘#myElement’).on(“click”, function() {… Then $(‘#myElement’).off(“click”) // or $(‘#myElement’).css(‘pointer-events’, ‘none’); will both work (but not ‘pointer-evenet’)… Demonstration : $(‘#myElement’).on(“click”, function() { alert(‘Hello world’); }); $(‘#myElement’).css(‘pointer-events’, ‘none’); // or : // $(‘#myElement’).off(“click”); <script src=”https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js”></script> <li id=’myElement’> <a href=”#”>Click here</a> (nothing should happen) </li> [ad_2] solved … Read more

[Solved] trying to get an absolute positioned div to center within another relative positioned div

[ad_1] You need to check the height and width of the element you’re centering on and set the top and left accordingly. $(‘.labelEdit’).click( function() { var x = $(“#editDialog”).width() / 2 – $(“#editItemDialog”).outerWidth() / 2; var y = $(“#editDialog”).height() / 2 – $(“#editItemDialog”).outerHeight() / 2; $(“#editItemDialog”).css({“top”: y, “left”: x}); $(‘#editItemDialog’).show(‘slow’); }); Basically, we’re setting the … Read more

[Solved] How to determine if the user is 18 years old and up using jquery?

[ad_1] Try this: Jquery: $(‘#datepicker’).datepicker({ onSelect: function(value, ui) { var today = new Date(), age = today.getFullYear() – ui.selectedYear; if(age >= 18) $(‘#age’).text(“User is 18 years old”); else $(‘#age’).text(“User is 18 not years old”); }, maxDate: ‘+0d’, changeMonth: true, changeYear: true, yearRange: ‘-110:-30’ }); Html: <input type=”text” id=”datepicker” /> <div id=”age” /> 5 [ad_2] solved … Read more

[Solved] Changing dynamically CSS DIV Background every certain time [duplicate]

[ad_1] You can use the setInterval function to change the image each X seconds and array to store the url’s: HTML <div id=”head”> content </div> CSS #head { background:#181015 url( ../images/bg_header.jpg) no-repeat; background-size: cover; min-height:520px; } JS var head = document.getElementById(‘head’), images = [‘img1.jpg’, ‘img2.jpg’, ‘img3.jpg’], i = 0; setInterval(function(){ if (i === images.length) i … Read more

[Solved] Remove text that starts with [closed]

[ad_1] You could use the following regex to replace from the first – character and any characters there after. $(“.colsborder h3″).each(function(){ var str = $(this).text(); var replaced = str.replace(/-.*/, ”); $(this).text(replaced) }); <script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js”></script> <div class=”colsborder”> <h3>Startoftext-needtoremove</h3> </div> This method would be faster than using the substring or split methods. 1 [ad_2] solved Remove text … Read more

[Solved] How I can showing div element after I hover another div? [closed]

[ad_1] You can solve this without JS, with pure css. HTML <div id=”button”> hover me </div> <div id=”my-menu”> my menu </div> CSS #my-menu, #button{ padding: 5px; border: 1px solid #000; } #my-menu{ display: none; } #button:hover + #my-menu, #my-menu:hover{ display: block; } Here is a JSFiddle: http://jsfiddle.net/p8pqquc9/ You will have a problem with this solution, … Read more

[Solved] Save value of a drop-down list and reassign it

[ad_1] var lastValue; $(‘#qty’).live(‘change’, function () { if ((this.value) == 10) { $(this).replaceWith($(‘<input/>’, { ‘type’: ‘text’, ‘value’: +(this.value) })); } else{ lastValue = this.value; } }); And then use lastValue to reset the value of the selectbox when you have to show it. EDIT : modified the jsfiddle, you jsut need to create the list … Read more

[Solved] How to disable / enable checkbox base on select (option) value [closed]

[ad_1] All you have to do is listen to the select and react when it changes. // Listen to the change of the <select> element $(“#typeofworkday”).on(“change”, function() { // Check the option value for “ferie” and disable the checkbox if ($(this).val() === “ferie”) { $(“#check1”).attr(“disabled”, “disabled”); // For all other options, enable the checkbox } … Read more

[Solved] Looking for a well written inifite scroll plugin [closed]

[ad_1] For infinite scrolling you should do ajax to load more content in your page each time when scroller hits the bottom of the page. $(window).scroll(function() { if($(window).scrollTop() + $(window).height() == $(document).height()) { angular.element(“#yourControllerId”).scope().loadMore(); } }); // angularJs code $scope.loadMore = function(){ // do ajax } [ad_2] solved Looking for a well written inifite scroll … Read more

[Solved] how to simulate a click on a href with jQuery [closed]

[ad_1] why not just display the tab you want rather than ‘click’ it? Is there extra code you are trying to get run at the same time? if($(“#fonction”).text() == “user”) { // Affichage de l’onglet Utilisateurs – this test works ! //hide current tab $(‘#tabs li a’).filter(‘.inactive’).addClass(‘inactive’); $(‘.container:visible’).hide(); //show new tab $(‘#tabs li a#TA’).removeClass(‘inactive’); $(‘.container#TA’).show(); … Read more

[Solved] How to get row data of a html table in jquery?

[ad_1] It would be easier to answer if you had posted your html, but I’m guessing it looks something like this: <table id=”tblTest”> … <td> <!– this is the third td in #tblTest (#tblTest td:nth-child(3)) –> <a …>Edit</a> <a …>Delete</a> </td> </table> Your jQuery selector is looking for all -tags in the third element. The … Read more

[Solved] Properties unavailable on my player ship object [closed]

[ad_1] JSFiddle here: http://jsfiddle.net/fjdC9/1/ appendPlayer: function (player, xPosition, yPosition){ player.appendTo(‘#huyakWrap’); player.attr(‘style’, ‘left: ‘ + xPosition + ‘px; top: ‘ + yPosition + ‘px’); $player = $(‘#player’); }, Once I figured out the actual problem, it was simply a case of you trying to find the element before it exists (as the first step of your … Read more