How to change value of object which is inside an array using javascript or jquery?

You have to search in the array like: function changeDesc( value, desc ) { for (var I in projects) { if (projectsi. Value == value) { projectsi. Desc = desc; } } } and use it like var projects = ... ; changeDesc ( 'jquery-ui', 'new description' ) UPDATE: To get it faster: var projects = { jqueryUi : { value: 'lol1', desc: 'lol2' } }; projects.jqueryUi.

Desc = 'new string (In according to Frédéric's comment you shouldn't use hyphen in the object key, or you should use "jquery-ui" and projects"jquery-ui" notation. ).

You have to search in the array like: function changeDesc( value, desc ) { for (var I in projects) { if (projectsi. Value == value) { projectsi. Desc = desc; } } } and use it like var projects = ... ; changeDesc ( 'jquery-ui', 'new description' ); UPDATE: To get it faster: var projects = { jqueryUi : { value: 'lol1', desc: 'lol2' } }; projects.jqueryUi.

Desc = 'new string'; (In according to Frédéric's comment you shouldn't use hyphen in the object key, or you should use "jquery-ui" and projects"jquery-ui" notation. ).

I mean give the object a name to fetch its data. Just like the object inside array.So,can I used in that way : jquery-ui. Jquery-ui.

Desc = .... – qinHaiXiang Jan 14 at 10:09 yes, create an object instead of a array – Aston Jan 14 at 10:24 1 your update won't work because of the hyphen - in the object name. You would have to write "jquery-ui": {} and projects"jquery-ui". Desc respectively.

– Frédéric Hamidi Jan 14 at 10:30 Thank you, I didn't know that. – Aston Jan 14 at 10:35.

You can use $.each() to iterate over the array and locate the object you're interested in: $. Each(projects, function() { if (this. Value == "jquery-ui") { this.

Desc = "Your new description"; } }).

You need to know the index of the object you are changing. Then its pretty simple projects1. Desc= "new string.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions