Jquery 使用属性数据加载内容

Jquery 使用属性数据加载内容,jquery,Jquery,我有一个公文包:当我点击一个图像时,会出现一个模式窗口,显示一个标题和一个较大的图像。标题文本存储在“数据标题类型”中。我想我可以从href属性获得更大的img url,但我不知道如何获得。你能帮帮我吗?谢谢 <div class="container"> <h2 id="titpl"></h2> </div> <div onclick="showInfo(this)" data-title-type="Work title"

我有一个公文包:当我点击一个图像时,会出现一个模式窗口,显示一个标题和一个较大的图像。标题文本存储在“数据标题类型”中。我想我可以从href属性获得更大的img url,但我不知道如何获得。你能帮帮我吗?谢谢

<div class="container"> 
    <h2 id="titpl"></h2>
</div>  

<div onclick="showInfo(this)" data-title-type="Work title" href="img/bigimg.img">
    <img src="img/img.jpg"/>
</div>

function showInfo(title) {
    var imgtitle = title.getAttribute("data-title-type");
    var imgref = title.getAttribute("href");
    document.getElementById('titpl').innerHTML = imgtitle
    <!-- what now? -->

}

我使用以下方法解决了这个问题:document.getElementById'imgsp'.src=imgref

我使用以下方法解决了这个问题:document.getElementById'imgsp'.src=imgref;