How can I change the text color with jQuery?

ID : 20432

viewed : 21

Tags : jquerytextjquery

Top 5 Answer for How can I change the text color with jQuery?

vote vote

100

Place the following in your jQuery mouseover event handler:

$(this).css('color', 'red'); 

To set both color and size at the same time:

$(this).css({ 'color': 'red', 'font-size': '150%' }); 

You can set any CSS attribute using the .css() jQuery function.

vote vote

81

Or you may do the following

$(this).animate({color:'black'},1000); 

But you need to download the color plugin from here.

vote vote

77

Nowadays, animating text color is included in the jQuery UI Effects Core. It's pretty small. You can make a custom download here: http://jqueryui.com/download - but you don't actually need anything but the effects core itself (not even the UI core), and it brings with it different easing functions as well.

vote vote

66

Actually emberjs supports two-way binding, which is one of the most powerful feature for a javascript MVC framework. You can check it out where it mentioning binding in its user guide.

for emberjs, to create two way binding is by creating a new property with the string Binding at the end, then specifying a path from the global scope:

App.wife = Ember.Object.create({   householdIncome: 80000 });  App.husband = Ember.Object.create({   householdIncomeBinding: 'App.wife.householdIncome' });  App.husband.get('householdIncome'); // 80000  // Someone gets raise. App.husband.set('householdIncome', 90000); App.wife.get('householdIncome'); // 90000 

Note that bindings don't update immediately. Ember waits until all of your application code has finished running before synchronizing changes, so you can change a bound property as many times as you'd like without worrying about the overhead of syncing bindings when values are transient.

Hope it helps in extend of original answer selected.

vote vote

55

Worth mentioning that there are many different solutions which offer two way binding and play really nicely.

I have had a pleasant experience with this model binder - https://github.com/theironcook/Backbone.ModelBinder. which gives sensible defaults yet a lot of custom jquery selector mapping of model attributes to input elements.

There is a more extended list of backbone extensions/plugins on github

Top 3 video Explaining How can I change the text color with jQuery?

Related QUESTION?