我知道这是非常基本的javascript但由于某些原因,我似乎无法在传递参数时使链接的onclick函数正常工作.
我试过转义引号,添加不同类型的引号并将原始变量添加为字符串.
我让它与下面的工作,但它说"XYZ未定义"
function renderLink(value, meta, record)
{
var type = record.data['name']; //value is XYZ
return '<a href="javascript:void(0);" onclick="getReport('+type+'); return false;"></a>';
}
function getReport(type){
alert(type);
}
Run Code Online (Sandbox Code Playgroud) <html>
<head></head>
<body>
<iframe id="num1" src="/idk">
<html>
<head></head>
<body>
<iframe id="num2" src="/idk2">
<html>
<head></head>
<body>
<div id="div1">
<div id="div2">
<a href="http://www.blablabla.com"></a>
</div>
</div>
</body>
</html>
</iframe>
</body>
</html>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我的问题是 - 如何使用 javascript 或 jquery 获取这两个 iframe 和两个 div 内 a 标签的 href 属性,我更喜欢 JS。(例如:“http://www.blablabla.com”)。
我需要在 svg<image>元素上设置 'xlink:href' 属性,如下所述。
我可以用 CSS 做到这一点吗?
我的页面内链接有问题.这是我在页面中使用的jQuery代码的一部分
$.fn.stopAtTop= function () {
var $this = this,
$window = $(window),
thisPos = $this.offset().top,
//thisPreservedTop = $this.css("top"),
setPosition,
under,
over;
under = function(){
if ($window.scrollTop() < thisPos) {
$this.css({
position: 'absolute',
top: ""
});
setPosition = over;
}
};
over = function(){
if (!($window.scrollTop() < thisPos)){
$this.css({
position: 'fixed',
top: 0
});
setPosition = under;
}
};
setPosition = over;
$window.resize(function()
{
bumperPos = pos.offset().top;
thisHeight = $this.outerHeight();
setPosition();
});
$window.scroll(function(){setPosition();});
setPosition();
};
Run Code Online (Sandbox Code Playgroud)
这是DEMO的一个例子
当我向下滚动时,一切正常,但是当我想要进入页面顶部时,这是不可能的.我知道问题是脚本div修复了,但我不知道如何解决它.有任何想法吗?
我想Link在某些条件下禁用:
render() {
return (<li>{this.props.canClick ?
<Link to="/">Test</Link> :
<a>Test</a>}
</li>)
}
Run Code Online (Sandbox Code Playgroud)
<Link>必须指定to,所以我不能禁用<Link>,我必须使用<a>
我正在尝试解析站点中的 HTML 内容,更改 href 和 img src。A href 更改成功,但 img src 未更改。
它在变量中发生了变化,但在 HTML 中没有发生变化(post_content):
<p><img alt="alt text" src="https://lifehacker.ru/wp-content/uploads/2016/08/15120903sa_d2__1471520915-630x523.jpg" title="Title"/></p>
Run Code Online (Sandbox Code Playgroud)
不是 _http://site.ru...
<p><img alt="alt text" src="http://site.ru/wp-content/uploads/2016/08/15120903sa_d2__1471520915-630x523.jpg" title="Title"/></p>
Run Code Online (Sandbox Code Playgroud)
我的代码
if "app-store" not in url:
r = requests.get("https://lifehacker.ru/2016/08/23/kak-vybrat-trimmer/")
soup = BeautifulSoup(r.content)
post_content = soup.find("div", {"class", "post-content"})
for tag in post_content():
for attribute in ["class", "id", "style", "height", "width", "sizes"]:
del tag[attribute]
for a in post_content.find_all('a'):
a['href'] = a['href'].replace("https://lifehacker.ru", "http://site.ru")
for img in post_content.find_all('img'):
img_urls = img['src']
if "https:" not in img_urls:
img_urls="http:{}".format(img_urls) …Run Code Online (Sandbox Code Playgroud) 我的问题是,如何翻译标签,标签内的链接在哪里。我正在尝试,但我只得到翻译 for ,msgid而不是 for msgid。
网站.html
<label for="id_data_protection" class="checkbox">
{% blocktrans %}Lorem <a href="/en/policy" target="_blank">Lorem ipsum</a> lorem ipsum test test {% endblocktrans %}
</label>
Run Code Online (Sandbox Code Playgroud)
django.po 文件
#: templates/pages/templates/contact.html:72
msgid ""
"Text <a href=\"/de/datenschutz\" target=\"_blank\">Text</a> "
"TextTextTextTextText"
msgstr ""
"Text <a href=\"/en/policy\" target=\"_blank\">Text Text</a> Text "
"TextTextText TextText"
Run Code Online (Sandbox Code Playgroud) 我有一个由 AlpineJS 提供的数据表:
<template x-for = "user in users": key = "user.Id">
Run Code Online (Sandbox Code Playgroud)
在 x-for 中,我可以使用 x-text 指令在 SPAN 字段中列出 user.Id 的值:
<span id = "user.Id" class = "text-gray-700 px-6 py-3 flex items-center" x-text = "user.Id"> </span>
Run Code Online (Sandbox Code Playgroud)
我需要在 HREF 属性的末尾连接 user.Id 的值,这将调用后端的路由来停用记录:
直接尝试设置HREF + user.Id属性,它不起作用,所以我想到了以下内容:
<script>
var uid = document.getElementById ("user.Id");
console.log ('uid value:' + uid.InnerText);
var link = document.getElementById ("link");
link.setAttribute ('href', 'http://api-paulinhomonteiro-com.umbler.net/cli/delete/<%= token%> /' + uid.innertText)
</script>
Run Code Online (Sandbox Code Playgroud)
通过动态设置属性,它工作得很好,但变量到达时未定义。
我该如何解决这个问题?我刚刚发现 AlpineJS,我不能再进一步了。有人能帮我吗?
我正在创建一个 chrome 扩展,我想通过电子邮件发送结果。
那么这就是a:
所以基本上,代码是
<a href={`mailto:{email}`}>email</a>
Run Code Online (Sandbox Code Playgroud)
这里似乎有什么问题?谢谢您的回答。
我想使用 SvelteKit 构建一个 Web 应用程序,其中一页列出所有项目(带有潜在的搜索查询参数),然后一页列出每个单独的项目。如果我必须用后端生成的所有内容以老式方式构建它,我的路径将是/items/所有项目的列表以及/items/123item123等。也就是说,要转到 item 的页面123,链接将带有href="123"will无论您当前处于索引 ( /items/) 还是某一特定项目的页面 ( /items/[id]),都可以工作。
使用 SvelteKit,如果我创建文件routes/items/index.svelte和routes/items/[id].svelte,那么routes/items/index.svelte将有路径/items,没有尾部斜杠,因此 的链接href="123"将导致/123,导致“未找到”错误。
但是,该链接可以在单个项目的页面上使用,例如/items/456。
这与传统 HTML 模型中的情况截然不同,在传统 HTML 模型中,来自/items/(或/items/index.html) 的链接与来自 的链接的工作方式相同/items/[id].html。
现在,您可以设置svelte.config.js一个选项,使其对应于 path ,但随后有了 path ,我们又遇到了同样的问题:一个值无法同时在索引和单个项目的页面中工作。trailingSlashalwaysroutes/items/index.svelte/items/routes/items/[id].svelte/items/[id]/href
我现在看到的唯一方法是使用绝对路径,但它不是很可组合。我的猜测是我做错了什么。