我有一些表单信息在我的脚本中显示信息鼠标悬停
我如何在我的原始表单中建立一个按钮,当我按下按钮时,这些都显示在一个新的窗口中。
我想所有关于我的标签,最大长度等信息显示在一个新的单独的页面
$('form').on('mouseover', 'input, textarea, select', function () {
var $tag = $(this);
var $form = $tag.closest('form');
var title = this.title;
var id = this.id;
var name = this.name;
var value = this.value;
var type = this.type;
var cls = this.className;
var tagName = this.tagName;
var options = [];
var hidden = [];
var formDetails = '';
var isRequired = $(this).prop('required');
var alignment = $(this).attr('align');
var maxlength = $(this).prop('maxlength');
var format = $(this).attr('Format');
var AutoComplete = '';
var selectInfo = '';
var readonly = $(this).attr('readonly');
var disabled = $(this).attr('disabled');
if ($form.length) {
$form.find(':input[type="hidden"]').each(function (index, el) {
hidden.push("t" + el.name + ' = ' + el.value);
});
var formName = $form.prop('name');
var formTitle = $form.prop('title');
var formId = $form.prop('id');
var formClass = $form.prop('class');
formDetails +=
"nnnFORM NAME: " + formName +
"nFORM TITLE: " + formTitle +
"nFORM ID: " + formId +
"nFORM CLASS: " + formClass +
"nFORM HIDDEN INPUT:n" + hidden.join("n");
}
if ((isRequired === 'undefined') || (isRequired === false))
isRequired = '';
else
isRequired = "nRequired: " + "Y";
if (format === undefined)
format = '';
else
format = "nFormat: " + format;
if (value === "")
value = "";
else
value = "nDefault Value: " + value;
if (readonly === undefined)
readonly = '';
else
readonly = "nReadOnly: " + "Y";
if (disabled === undefined)
disabled = '';
else
disabled = "nDisabled: " + "Y";
if ($(this).hasClass('ui-autocomplete-input'))
AutoComplete = 'AutoComplete';
if ('SELECT' === tagName) {
$tag.find('option').each(function (index, el) {
options.push(el.value);
});
maxlength = 'Not required';
selectInfo +=
"nSelect Options:nt" + options;
}
var tempTitle =
"nName: " + name +
"nType: " + tagName + " - " + type +
"nMaxlength: " + maxlength +
isRequired +
value +
readonly +
disabled +
format +
selectInfo;
if (AutoComplete !== '')
tempTitle += "nAutoComplete: Y";
$(this).each(function () {
$.each(this.attributes, function () {
// this.attributes is not a plain object, but an array
// of attribute nodes, which contain both the name and value
if (this.specified) {
//console.log(this.name, this.value);
}
});
});
//tempTitle += formDetails;
tempTitle;
$tag.prop('title', tempTitle);
$tag.on('mouseout', function () {
$tag.prop('title', title);
})
});
你在找这个吗:
注意:弹出窗口被阻塞在这个"运行代码片段"。请在您那边试试。
<script type="text/javascript">
var info1 = "some information 1";
var info2 = "some information 2";
var info3 = "some information info3";
var info4 = "some information info4";
$("#openPopup").click(function(){
var newWin = window.open("","infowindow","height=200,width=300");
newWin.document.write("<p>"+info1+"</p>");
newWin.document.write("<p>"+info2+"</p>");
var bodyElem = $(newWin.document).find("body");
if(bodyElem)
{
bodyElem.append("<p>"+info3+"</p>");
bodyElem.append("<p>"+info4+"</p>");
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<button id="openPopup">Open Popup</button>