1

I have an HTML element which has a data-click attribute with the below string. I want to change the src value inside the string. How to do it with javascript in such a way that it works for all similar strings. Can someone help me?

Tried regex but not sure if it works for all.

"Meetings.renderMiniPopup('/p/p1/meetings/mini_popup?member_id=55218&src=nuxgml')"
1
  • 3
    Can you please show what regex you have tried? Commented Jul 23, 2019 at 7:13

1 Answer 1

1

You can use a combination of Regex and the replace method.

str.replace( /(Meetings\.renderMiniPopup\(')([^']*)('\))/ , '$1'+ '<MY NEW VALUE HERE>' +'$3' )
Sign up to request clarification or add additional context in comments.

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.