[英]How to pass a data-title from a page to a fancybox form element?
I have se a jsfiddle to help you to understand my goal 我有一个jsfiddle可以帮助您了解我的目标
http://jsfiddle.net/CE2MZ/1/ http://jsfiddle.net/CE2MZ/1/
What I am trying to do is to pass a php variable from my page to a fancybox form through data-title. 我想做的是通过数据标题将php变量从页面传递到fancybox表单。
$(document).ready(function() {
$(".modalbox").fancybox({
'closeBtn' : false
});
$(".action-xam").click(function(){
//Get some info like the title
var title = $(this).next("div").data("title");
//Insert the info into xam
$("#krimmeno").val(title);
});
});
not sure what you want but if you replace the .next
by .find("div:first-child")
it will select the first div
in your link
or you can target the class .find(".service-box")
. 不确定您要什么,但是如果将
.next
替换为.find("div:first-child")
,它将选择link
的第一个div
,或者您可以定位类.find(".service-box")
。
The .next
is for sibling elements. .next
用于同级元素。
var title = $(this).find("div:first-child").data("title");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.