JQuery Alter CSS Value of Left

I am trying to move a div Left a specified amount of pixels I'm using a slider that I got from here:


So from the example my div looks like this:

<div class="horizontal_slider"
        style="left: 0px;"
        onmousedown="slide(event, 'your_slider_id',
        'horizontal', 100, 0, 100, 101,
        0, 'your_display_id');" >&nbsp;</div>

And If I adjust left: 0px the slider the move along its line, I've been trying to alter the left from an ajax response that looks like this:

var stateofmindint = $.ajax({ url: "function.php?state=1", async: false }).responseText;

And I try to change its Left style like this:

$("#your_slider_id").css({"left": stateofmindint +"px"});

But for some reason it stays at Left:0px, I've tried to remove the style tag in the div, but to no effect, I also tried referencing the class instead of the ID but nothing seems to be working! I am definitely getting a value everytime through ajax. Any advice would help thank you!


Check with an alert/console.log what's the response of your ajax script or try setting "stateofmindint" to a known value in code to test what part has the bug.

Theres something weird going on. On that page you link I tried using firebugs console to see the sliders left value with the following

$("#horizontal_slider_2").css("left", "30px");

But jQuery returns null with that selector. The following works:

document.getElementById('horizontal_slider_2').style.left = '30px';

So theres some bug going on with jQuery or that slider code

Need Your Help

How do I test the title of a page from an RSpec view spec?

ruby-on-rails ruby-on-rails-3 rspec title rspec2

I'm learning RSpec 2 with Rails 3. In order to set the contents of the tag in the layout for each page, I have a helper that can be used to set the title and then return it:

Perl performance: for(1..200000) vs for($_=1;$_<=200000;$_++)

perl performance memory

for(1..200000) {...} vs for($_=1;$_&lt;=200000;$_++) {...}

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.