w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Jquery.height() return 0 for an img tag
The code you shared by itself seems to do the job I even ran it in a jsfiddle link: var jdialog = $('<div id="avatar_button_clipdiv" style="width: 68px; height: 125px"> <img width="50" height="100" src="https://www.google.co.il/images/srpr/logo4w.png" style=""/> </div>').appendTo('body'); console.log(jdialog.find('img')); console.log(jdialog.find('img').width(),jdialog.find('img').height()); does this happes on a specific browser?

Categories : Jquery

How do I return the box height to original state when clicked again in JQuery?
Maybe not the best solution, but depending on the div height this works: jQuery/JavaScript: var heights = $btn.hasClass('opened') ? 300 : 200; CSS: .box { height: 200px; width: 200px; background-color: orange; } jsFiddle

Categories : Javascript

Why does jQuery only return integer height if setting a double value clearly renders differently?
Using jquery.height() actually converts it to the actual amount of pixels it is taking up on the screen. You may find, if you iterated through every div on your page a mixture of height 10's and 11's, since you can't render something on only half a pixel, to actually render things that take half a pixel you would need to decide whether it will take a pixel or not. The browser will alternate between which divs do and don't to try and get the best possible result.

Categories : Javascript

How to return original height to dynamic-height content with Javascript?
Could be done using data(): http://jsfiddle.net/sWf9J/2/ function toggleModule(module){ var selectModule = $('div.module[data-module=' + module + ']'); if(!selectModule.data('originalHeight')) selectModule.data('originalHeight',selectModule.height()); if(selectModule.hasClass('open')){ selectModule.animate({'height':'40px'},200); selectModule.removeClass('open').addClass('closed'); } else if(selectModule.hasClass('closed')){ selectModule.animate({'height':selectModule.data('originalHeight')},200); selectModule.removeClass('closed').addClass('open'); } }

Categories : Jquery

Finding the actual text height AS3
Your question highlights a legacy of weak semantics in the Flash typographic APIs. The textHeight property represents the relative size of the typeface in pixels, it doesn't account for the pixel representation of the particular glyphs (the individual letter shapes) in the TextField. As far as I know there is no direct programatic way to measure a glyph with Flash. However, you could bitmap the textfield and use getPixel to guess: var tf:TextField = …your textfield… var wide:int = tf.width; var tall:int = tf.height; var bmpd:BitmapData = new BitmapData(wide, tall, true,0xFFFFFFFF); bmpd.draw( tf ); var totalPixels:int = wide * tall; var index:int = totalPixels + 1; var useIndex:int; var xPixel:int; var yPixel:int; while (--index > 0) { useIndex = index - 1; xPixel = useIn

Categories : Actionscript

jQuery - get tallest image's height, apply other images' height difference to top margin
Try this: function createGrid() { var imgs = $('.hlist figure > img'); var maxImgHeight = 0; imgs.each(function () { var imgHeight = $(this).outerHeight(); maxImgHeight = maxImgHeight > imgHeight ? maxImgHeight : imgHeight; }); imgs.each(function () { var margin = maxImgHeight > $(this).outerHeight() ? (maxImgHeight - $(this).outerHeight()) : 0; $(this).css("margin-top", (margin + "px")); }); } The first each loop looks for the tallest height and stores it in maxImgHeight, as you originally had planned. The second each loop calculates and applies the margin for each image. The conditional assignment will cause the margin-top for the tallest image to be 0.

Categories : Javascript

finding height and width of content after editing with nicedit
I'm still a noob at programming, so there might be much better solutions. But I can show you what I have done with a similar problem. Not sure if that is what you need though. function getHeight(id) { if(document.getElementById(id) == null) return Number(0); else return document.getElementById(id).offsetHeight; // Change to .offsetWidth to gain width :) } You create and call this function by sending the ID og the element that you want to get the width/height. The function is made so it will first check if the ID is present, if not it returns 0. If it is, it returns the inner width/height. If you are 100% sure that the ID you are asking for is present you only need the last line of the function. You could use it like so: var h = getHeight("draggable"); This will r

Categories : Javascript

jQuery Error: Object has no method 'height', this.height()
this is a DOM element. You want a jQuery object. Try $(this).height() : function Test(){ $("#list li").each(function(){ var h = $(this).height() + 50; $(this).height(h); }); }

Categories : Jquery

jQuery Set height of 2 independent lists first list li the same height as second li
http://jsfiddle.net/EvspT/ $(document).ready(function() { $('.extraQuestionName li').each(function(i) { $('.extraQuestionValue li').eq(i).height($(this).height()); }); }); The each() function has an index parameter. This loops through the li elements in the first list, and uses eq() to find the item with the same index in the second list, then set the height.

Categories : Jquery

Javascript / jQuery - Is there a performance difference between height() and .css({'height'})
Read the Source, Luke. jQuery.prototype.height: //snipped to end: return value === undefined ? // Get width or height on the element, requesting but not forcing parseFloat jQuery.css( elem, type, extra ) : // Set width or height on the element jQuery.style( elem, type, value, extra ); jQuery.prototype.css: return value !== undefined ? jQuery.style( elem, name, value ) : jQuery.css( elem, name ); The difference between the two is what's done before going over the matched elements, and that extra parameter that's passed in .height. What could rationally cause a big slowdown? I've no real idea. Maybe it has to do with optimizations a js engine can do in one, but not the other. More likely than not, the perf test is bad (testing these things correctly is very ha

Categories : Javascript

C : Cannot access memory error, when finding recursively an AVL tree height
Your avl_insert function is a recursive one and your program is running out of stack memory. Using smaller sized variables will help you a little (using short instead of long int etc.) but you will encounter the same issue a little later again. In such cases, it makes sense to look for an optimization in the base case for the recursive function.

Categories : C

jQuery, min-height based on browser height
Use css(). var height = $(window).height(); $(".single-block").css("min-height", height); or simply: $(".single-block").css("min-height", $(window).height());

Categories : Jquery

Equalize height on two floating divs when window size is greater than specified width, then return to original height when window width is below
Working jsFiddle Demo Just remove height from elements: function originalHeight(group) { group.css('height', ''); }

Categories : Jquery

Finding the full height of the content of a page/document that can have absolutely positioned elements
If this can give you some help: alert($('body')[0].scrollHeight); also this command give me the same value: alert($('body').context.height); I tryed with this script but it should be improved cause it gives different result with different browser. var k=0; var off = document.documentElement.offsetHeight; $('#but').click(function(){ //let's go faster here (first 3 before the user touch something $('html body').scrollTop(9999999); //best scroll var k=$('html body').scrollTop();//getrealscroll $('html body').scrollTop(0);//backscrollto0 alert(off+k);//the height }); I would like to suggest you a script that, considering if there is absolute element, find the height: <button id="but">Scan me</button> var maxhabs = 0; var maxhrel = 0; var realh = 0; va

Categories : Javascript

Javascript / jQuery : get height when max-height is set to 0
My first question would to be why are you using max-height: 0; is there something else you can use? Like hide() show() which use display: none the only thing I can thing of would be to remove the max-height css get the height and then reapply the max-height: $('.div').css('max-height', 'none') console.log($('.div').height()) $('.div').css('max-height', '0') This should happen fast enough that you wont see the element but it could be wise to hide it before removing the max-height with: $('.div').hide() $('.div').css('max-height', 'none') console.log($('.div').height()) $('.div').css('max-height', '0') $('.div').show()

Categories : Javascript

jquery .height() not pulling the height
If you want a one-liner, try this: $(".zebra-helper").fadeToggle("slow", "linear").height($("#main-content-pane").height()); If you want to use again the same height in that block, store it into a variable, then use it when needed: var h = $("#main-content-pane").height(); $(...).height(h);

Categories : Jquery

Click to increase height and decrease back to original height when click again with jQuery?
$("button").toggle(function(){ $("#section").height($("#section").height()+300); },function(){ $("#section").height($("#section").height()-300); }); reference toggle

Categories : Jquery

Finding specific key and return value in a multidimentional array
given that the two arrays exist above this block as $schedules and $allmembers, the following should work. foreach($schedules as &$event) { $participants = array_flip(explode(',', $event['participants'])); $addThese = array(); foreach($allmembers as $member) { if (isset($participants[$member['id']])) $addThese[] = $member; } $event['participants'] = $addThese; } unset($event); print_r($schedules);

Categories : PHP

onLoad return 0 as width and height
In this line: img.onLoad = this.onLoad(img); you are incorrectly calling this.onLoad immediately, rather than passing that function as the load handler. Your code thus completes without ever waiting for the images to be actually loaded. You also have the case wrong - the handler property should be called img.onload rather than img.onLoad. Note that the .onload event handler will be called with the image as its this context variable rather than having it passed as a parameter, so you would use this (representing the image, not your class) inside that event handler. The alternative would be to write: var self = this; img.onload = function() { self.onLoad(this); }

Categories : Javascript

finding minimum product value and return the multiplied values from matrix
Second output argument of min returns the index. [C, I] = min(C(:)); A = A(I); B = B(I); Note that if there are more than one element that are equal to minimum the first one in C(:) will be returned.

Categories : Matlab

Return an object to its original rotation and height unity C#
I'm not sure if the player would be able to move when he gets hit, but you could save the current values to local variables (for example: Transform transformOnHit). After you complete the roll, you can use your own provided code to translate and rotate back to the original transform.

Categories : C#

calculate and set the height for some div (initial settings). When the height of the browser window is changed --> change the height for div
is that what you are looking for? api.jquery.com jQuery(document).ready(function () { $(window).resize(function() { var height = document.documentElement.clientHeight - 500; if (height < 135) { height = 135; } document.getElementById('left_space').style.height = height + 'px'; jQuery(window).resize(function () { var height = document.documentElement.clientHeight - 500; if (height < 135) { height = 135; } document.getElementById('left_space').style.height = height + 'px'; }); }); });

Categories : Javascript

Changing height of jQuery Mobile "select" with jQuery?
You are missing the obvious. Your original select is not longer visible. Also as you can see new one is just custom combination of <div>'s and <span>'s. New custom select box will not inherit css from the old one. New select box CSS structure needs to be changed in order for this to work. Working example: http://jsfiddle.net/Gajotres/PMrDn/107/ HTML: <div class="ui-grid-a"> <div class="ui-block-a" style="width: 80%;"> <div data-role="content" class="accountTransferLabels" style="padding-left: 0;"> Amount: </div> <input type="text" autocomplete="off" class="translate" placeholder="0.0" data-clear-btn="true" autofocus required autocorrect="off" autocapitalize="off" data-theme="d"/> </div> &l

Categories : Javascript

I am trying to make a height calculator based on genetics. But javascript doesn't return the expected answer
Your input values are strings, you need to parse them to integer (using parseInt()) before doing numeric operations. Working Demo Try the below code: function calculate (d, m) { if (document.getElementById('male').checked) { var result = (parseInt(d,10)+parseInt(m,10)+13)/2; document.write(result); } else if (document.getElementById('female').checked) { var result = (parseInt(d,10)+parseInt(m,10)-13)/2; document.write(result); } else { alert("Choose a gender!"); } } Note: As already pointed out by others, it is not good practice to use document.write because they repaint the whole screen. Instead you can have a output div and assign the result to its innerHTML like below. document.getElementById('output

Categories : Javascript

Increasing TextSize of TextView and then Decreasing It Doesn't return to normal height of view element
Whether this answer helps much or not, I think android:layout_weight="0" is redundant. A weight statement (say android:layout_weight="1") is also more usually accompanied by a android:layout_height="0dp" or android:layout_width="0dp", depending on the orientation of the containing LinearLayout.

Categories : Android

require.js with jquery ui, not finding jquery
You first need to define the jquery dependency: define('jquery', [], function () { return root.jQuery; }); Then you can use 'jquery' to load other libs depending on jQuery.

Categories : Javascript

jQuery finding data from div tag
.find() looks for descendants of an element but in your case the closest div is itself the .btn-group, so you can just filter closest() to make sure you get the div with the class you need $('.paid-today').click(function(){ alert($(this).closest('div.btn-group').data('pay_for_month')); });

Categories : Jquery

jQuery
  • index finding
  • Start at the img and work your way up: $(".es-carousel").find("img[src*='something']").parents('li').index(); http://jsfiddle.net/zyvTD/

    Categories : Javascript

    Finding a property of jQuery element
    You need to use .attr() here because, target is an attribute here var classNames = parent.find("input").attr("target"); or var classNames = $(this).prev().attr("target");

    Categories : Javascript

    Finding whether checkbox is checked or not using jquery
    try this: select :<input type="checkbox" id="someId" name="someId" value="" checked /> <input id="btnSubmit" type="button" value="Submit"/> $("#btnSubmit").on("click",function(){ if ($("#someId").is(':checked')) { alert("checked"); } else { alert("unchecked"); } }); working fiddle here: http://jsfiddle.net/tLebs/1/ i hope it helps.

    Categories : Javascript

    Finding closest element without jQuery
    Here's how you get the closest element by tag name without jQuery: function getClosest(el, tag) { // this is necessary since nodeName is always in upper case tag = tag.toUpperCase(); do { if (el.nodeName === tag) { // tag name is found! let's return it. :) return el; } } while (el = el.parentNode); // not found :( return null; } getClosest(th, 'tbody');

    Categories : Javascript

    Finding case sensitive string in a cell from a specific list and return a value from the list
    Assuming the following: Sheet 1, column a = Sheet1!A:A Sheet 1, column b = Sheet1!B:B Sheet 2, column a = Sheet2!A:A Sheet 2, column b = Sheet2!B:B You can simply insert an INDEX MATCH into Sheet1!B1 =INDEX(Sheet2!B:B,MATCH(Sheet1!A1,Sheet2!A:A,0))

    Categories : Excel

    jquery css cannot set the height
    Something on your page is conflicting with jQuery. Using $ is the problem in this case. Try this instead... (function($) { $(function(){ $('#nimble_portfolio_grid_1').addClass('importantRule'); }); })(jQuery); That will run whatever code is inside the enclosure with jQuery passed in as the $ parameter and solved your problem. Alternatively, if you're not adding any more code, just change the $ to jQuery like this... jQuery(function(){ jQuery('#nimble_portfolio_grid_1').addClass('importantRule'); }); Finally, the best thing to do would be to use CSS correctly and just specify the element by ID... <style> #nimble_portfolio_grid_1 { height: 5320px !important; } </style>

    Categories : Jquery

    Finding value of textbox in same row as clickable element using jquery
    <script> $(document).ready(function(){ $(".btn-primary").click(function(){ qty = $(this).parents('.cart').find('.qty').val(); alert(qty); }); }); </script>

    Categories : Javascript

    Need a more elegant way of finding an element in the dom tree with jQuery
    I think you want to do this: $(".postmetadata:contains('Vancity Buzz')") .closest('.read') //Closest will get you to the parent with class .read .siblings('.articleImageThumb').hide(); //this will get you all the siblings with class articleImageThumb this refers to window there not the element you are checking in the if condition. Fiddle I don't know if your intention is to have the empty anchor tag just by hiding the image. if so just add a find to it.

    Categories : Javascript

    jQuery not finding inputs in table cells
    $(this).text() will somehow 'remove' the html tags, but it will keep all the characters present as text in your nodes. This will include the white spaces. With your example, the .text() call will return " cell " (space - "cell" - space) or " " (space - space) - as shown in this fiddle. Identifying a cell based on its sole .text() value is a poor choice indeed. Try mithunsatheesh' answer, or try to add some id or class attribute to your cell, and use the appropriate selector. If you gave more context, maybe someone could give you a more appropriate answer.

    Categories : Jquery

    Finding matching selector element within jQuery.on()
    Your .on() call is using the delegated event syntax with the '.foo' selector specified, so jQuery will set this to the .foo element. $(document).on('click','.foo','click',function(e) { console.log(this); }); As explained by the documentation: When jQuery calls a handler, the this keyword is a reference to the element where the event is being delivered; for directly bound events this is the element where the event was attached and for delegated events this is an element matching [the specified] selector. (Note that this may not be equal to event.target if the event has bubbled from a descendant element.) Note that specifying 'click' in the third (data) parameter of .on() is kind of redundant. If you will be calling the same function for more than one type of event you can get t

    Categories : Jquery

    Finding dynamic checkbox in jquery , But using only a function?
    For dynamically added controls you will have to delegate the events handler function to the controls. It can be achieved using .on() in jquery Have a look: http://api.jquery.com/on/ For eg: $( '#wrapper' ).on( 'click', 'a', function () { ... }); where wrapper is your static element and a is your dynamic element like : <table id="wrapper"></table>

    Categories : Javascript

    jQuery .filter() method doesn't return elements as expected in jQuery 1.5.1
    jQuery 1.5.1 is very outdated While the last features added to .filter() were in jQuery 1.4 (filter by selector in 1.0), there have been fixes since. Your problems seem to be between jQuery 1.5.1 and IE. You should use jQuery 1.10.1 instead.

    Categories : Jquery

    Toggling height of div in jQuery
    Fix is simple: $("#topbar").toggle(function () { $(this).animate({ height: 40px }, 200); }, function () { $(this).animate({ height: 10px }, 200); }); You just need to add px units to the height value. See demo at: http://jsfiddle.net/audetwebdesign/3dd3s/ PS Some of the other posted answers show a better way of coding this type of animation. I simply demonstrated how to fix the bug. Note that this use of .toggle has been deprecated since jQuery 1.8. Reference: http://api.jquery.com/toggle-event/ Why The Unit is Needed Some of the other solutions involve the jQuery .height() function, which returns a unit-less pixel value. In this case, the computed value is coerced/cast to be a pixel value, so the 'px` unit is not required. In the original exa

    Categories : Javascript



    © Copyright 2017 w3hello.com Publishing Limited. All rights reserved.