I have a div:
<div id="div" style="height:150px; border:solid thin blue;"></div>
is there a way to retrieve the original div height? The div is resizable, so the user may have resized it before my code loads.
Note: my code is a jQuery plugin, so I have no clue about what happened to the element before my plugin is called (so please don't tell me to store height in element data...)
jqFiddle in this demo, I want to get the 150 after resizing the div.
Any help would be greatly appreciated!
No, because resizable() method override inline style height value.
You need to store it somewhere else.
For example before making div resizable:
var originalHeight = $('#div').height();
$('#div').resizable();
$('#cmd').button().click(function(){
alert(originalHeight);
});
I don't know of a way to get old data from the DOM, but could you not insist on the plugin having an init function called and get the values then? You could also advise in your documentation that the elements not be moved until you've completed the init function, although if it's called via .ready() this should occur before the user has a chance to blink anyway.
How is the div resizable, using jquery-ui?
Another option might be to get the page again using ajax and then parse the page, but it would be a lot of effort and very messy.
originalHeight=0;
$(document).ready(function()
{
originalHeight= $("#div").height()
});
Related
I have been trying to get this to work for the past 6 hours and I am just unable to do it right. I've looked at the questions and solutions on SO as well to no avail. What am I doing horribly wrong?!?
All I have is a html5 page with no background. In my javascript code I call upon this method when the document is ready:
/*
* Initializes the landing page.
*/
function initializeLanding(){
$('body').css({
'backround':'url("http://40.media.tumblr.com/290e7a272b492735ddf8cd968e657d05/tumblr_nhmg6xYnv41u7ns0go1_1280.jpg")'
});
}
It should be something stupidly simple, and yet here I am. I've tried using single quotes, double quotes, without multiple attributes, etc. I would also much rather not use CSS or DOM properties to change the background, as I have set up way points along the page to change the background upon scrolling past them.
Also, if I call the .css() method and put in new attributes, will it overwrite all the old ones, or just the stated attributes in the latest css() call?
Update: here is where I call the function:
var main = function(){
$(".owl-carousel").owlCarousel();
lorem();
initializeLanding();
}
$(document).ready(main);
you have a spelling mistake.
backround => background.
check this demo
you have a spelling mistake. replace backround to background
function initializeLanding(){
$('body').css({
'background':'url("http://40.media.tumblr.com/290e7a272b492735ddf8cd968e657d05/tumblr_nhmg6xYnv41u7ns0go1_1280.jpg")'
});
}
I'm new here so i'll ask. I have a dynamic slider that gets the height dynamically. So I need to get this dynamic height and pass the value to the top css.
I added this function in the function.js file
$('.navbar-inverse').css("top", 922);
and it gets the value, but I need this value to be dynamic and not inserted manually.
The height value comes from a class name fs-stretcher
Any help would be great. tks
Try
$('.navbar-inverse').css("top", $('.fs-stretcher').height())
This needs to be part of an event handler if you want the dynamic value. You call it a slider but I'm not sure what exactly the event is so we'll go with...scrolling down the page (just change the word scroll to whatever you use).
$('.navbar-inverse').on('scroll', function() {
$(this).css('top', $('.fs-stretcher').height());
});
I am running a bg slider..."Supersized - Fullscreen Slideshow jQuery Plugin"
what i need is when a background changes some contents in a specific div must also change...
here i found a code line from script
if (options.slide_captions)
$('#slidecaption').html(options.slides[currentSlide].title);
this one pulls the image title to a specific div, but i want to load unique div for each background change...
or is there any other ways to do??
i have very little knowledge in jquery...
please help
advance thanks...
you can write this:
if (options.slide_captions) $('#slidecaption').html(options.slides[currentSlide].title, function(){
//write the code that load the unique div
});
tell me if it works
http://buildinternet.com/project/supersized/docs.html#theme-after
Check-out the theme.afterAnimation( ) documentation. You can set it to a function that changes the content after the slide changes.
I need this page: http://winteradagency.com/mrw/index.php
so that when you mouseover the different small images (actually a set of them) the text below changes from text into an image (which is a larger image of the smaller one) I used to use Fireworks for that sort of thing but I'm thinking that there must be an easier way using a combination of a div tage and javascript.
Any ideas for something simple?
thanks!
http://fancybox.net/
lightbox, etc...
The jQuery CYCLE plugin might suit your needs. It transforms a list of elements into a scrolling pane. You could simply disable automatic scrolling on initialization, and set the time between slides to 0. Then you can call the "slide number" in the callback for the mouseover event on the smaller thumbnails.
Cycle is here: http://malsup.com/jquery/cycle/
Your application is very similar to this example: link text
This question has a similiar situation (replacing an input with an image) with an answer that might work for you. Note: it uses jQuery.
Edit:
For your situation you could do something like this for each image:
$('img#id').hover(
function() {
('div#id').hide().after('<img src="image.jpg" />');
},
function() {
('div#id').show();
}
);
changing the 'img#id' to the id of the image and 'image.jpg' to the corresponding big image.
I tried some plugins but they all come with their own styling which takes quite some time to get rid of. Is there any plugin with minimal styling (or a really simple way) to apply custom background to select element? I just need something very simple.
Thanks
I found this one. It even degrades automatically if JavaScript is disabled.
http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/
With jQuery am using lines like this in my dom ready function :
$(".overlay").css("top","300px");
Goes like this in the header:
<script type="text/javascript">
jQuery(document).ready(function(){
$(".overlay").css("backgroundColor": "#0f0");
});
</script>
.overlay is the class of the div i wanna change and then comes the css property and its value.
Hope this helps.