Hello! I can’t replace the url in the script by clicking on the div. How to implement it? Thank you in advance!

<div id="button">Кнопка</div> 

Here is the script itself

 <script> $('#button').click(function () { $.modal({ type: 'ajax', url: 'home/1.html' }); }); </script> 

    1 answer 1

    rewrite the function like this

     <script> $('#button').click(function (url) { $.modal({ type: 'ajax', url: url }); }); </script> 

    and then before calling me, change url

    Taking into account the last comment where it is painted that yes how can you do this: When you click on the picture, you change the global URL variable. And the div click clipping function becomes

    <script> $('#button').click(function () { $.modal({ type: 'ajax', url: url }); }); </script>

    • where url is a global variable containing the address of the corresponding selected image.
    • Sorry for my stupidity, a little more) - DOsS
    • you alter someone else's code or do yours? I'm just asking what you can - you can describe what it is for, and maybe an elegant solution will be found - Ale_x
    • The code is not mine, the task is this: 1. there are several pictures and one button, you need to replace the url in the script when you click on a separate picture, so that clicking on the button loads certain information for a specific page. Something like this. - DOsS