更改网站模板上的占位符文本
changing the placeholder text on a site template
我正在使用 Squarespace 模板并尝试更改搜索占位符文本(键入以搜索...)。
我尝试搜索他们的论坛,但没有任何帮助。我认为一些简单的 jquery 可以解决问题,但我想不通。
代码如下:
<form id="yui_3_17_2_2_1421895144095_1398" _lpchecked="1">
<input placeholder="Type to search..." type="text"
spellcheck="false" value="" id="yui_3_17_2_2_1421895144095_1397">
</form>
试试这个。
$("form").find("input").attr("placeholder", "Recherche");
或者将它放在 body
关闭标签的正上方
$(function () {
$("form").each(function () {
var inputElm = $(this).find("input");
var ph = inputElm.attr("placeholder")
if (ph && ph === "Type to search...") {
inputElm.attr("placeholder", "Recherche");
}
});
});
如果你想要 YUI(squarespace 原生支持),试试这个。
Y.one('form').one('input').setAttribute('placeholder', 'Recherche');
或
Y.all('form').each(function (node) {
var inputElm = node.one('input');
var ph = inputElm.getAttribute('placeholder');
if (ph && ph === "Type to search...") {
inputElm.setAttribute("placeholder", "Recherche");
}
});
我正在使用 Squarespace 模板并尝试更改搜索占位符文本(键入以搜索...)。
我尝试搜索他们的论坛,但没有任何帮助。我认为一些简单的 jquery 可以解决问题,但我想不通。
代码如下:
<form id="yui_3_17_2_2_1421895144095_1398" _lpchecked="1">
<input placeholder="Type to search..." type="text"
spellcheck="false" value="" id="yui_3_17_2_2_1421895144095_1397">
</form>
试试这个。
$("form").find("input").attr("placeholder", "Recherche");
或者将它放在 body
关闭标签的正上方
$(function () {
$("form").each(function () {
var inputElm = $(this).find("input");
var ph = inputElm.attr("placeholder")
if (ph && ph === "Type to search...") {
inputElm.attr("placeholder", "Recherche");
}
});
});
如果你想要 YUI(squarespace 原生支持),试试这个。
Y.one('form').one('input').setAttribute('placeholder', 'Recherche');
或
Y.all('form').each(function (node) {
var inputElm = node.one('input');
var ph = inputElm.getAttribute('placeholder');
if (ph && ph === "Type to search...") {
inputElm.setAttribute("placeholder", "Recherche");
}
});