2

What if I had somthing like this

<div class="fb-like-box" data-href="" data-width="292" data-show-faces="true" data-stream="true" data-header="false" colorscheme="light"></div>

and I wanted to use jQuery to change the attribute "colorscheme" to colorscheme="dark" and change "data-header" to data-header="false" so on and so fourth.

These changes would need to happen when clickong on a button or image or some other type of action... I can get the action part down its just how would I call for change for those specific variables if you will.

I also need help changing all the other ones like data-href, data-width, and data-show-faces

Huge Thanks In Advance!

2 Answers 2

1

First, you should write the click event over button or image like

$('#buttonID').click(function(){
    $(".fb-like-box").attr({ "data-href": "#", "colorscheme":"dark", "data-value": "I was updated" });
});

Attribute of div will update only when you click on the selected button.

Sign up to request clarification or add additional context in comments.

Comments

0

You can change any attribute by using jquery .attr() method.

If you are having troubles with minus symbol in attribute name, you can escape it with "". Like this:

$("#SomeId").attr({ "data-href": "javascript:void(0)", "data-value": "oh hi there!" });

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.