弹出式<a> tag on click i need to pass href

时间:2016-11-15 16:37:01

标签: popup fancybox

I am using Fancy popup in a tag on click it show it working fine. Below my code

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<link rel="stylesheet" href="http://fancyapps.com//fancybox/source/jquery.fancybox.css?v=2.1.5" type="text/css" media="screen" />
<script type="text/javascript" src="http://fancyapps.com//fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
<a href="#myDivID" id="fancyBoxLink">Click Me</a>
<div style="display:none">
    <div id="myDivID">
          <input type="text" id="fname" name="fname" placeholder="First Name" required="true" class="form-text" />          
    </div>

</div>


<script type="text/javascript">
jQuery(document).ready(function($) {
    $("a#fancyBoxLink").fancybox({
       // 'href'   : '#myDivID',
        'titleShow'  : true,
        'transitionIn'  : 'elastic',
        'transitionOut' : 'elastic',
        'openEffect'    : 'elastic',
        'closeEffect'   : 'elastic',
        'maxWidth'  : 800,
        'maxHeight' : 600,
        'fitToView' : false,
        'width'     : '70%',
        'height'        : '70%',
        'autoSize'  : false,
        'closeClick'    : false
    }); });
</script>

Now My problem is i want to i want to call that a tag link in this html so i added below script

<script>
    $(document).on('click', 'a', function(e) {
        e.preventDefault();
        e = $(this).attr('href');//this gets the href
        //e = $(this).text();//This gets the text
        $('#fname').val(e);
    });

    </script>

I want to pass href to that input box so I change this to <a href="#myDivID" id="fancyBoxLink">Click Me</a> this <a href="www.domain.com" id="fancyBoxLink">Click Me</a> after this it stop working how i make it as working

0 个答案:

没有答案