如何引用加载了当前正在运行的javascript的script元素?
情况是这样的。我有一个“主”脚本被加载在页面的高处,在HEAD标签下的第一件事。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lan
我正在为我的网站制作一个非常基本的菜单,并且我已经使用了边框底部属性来给这些项目加下划线。我想要的是突出下划线粉红色,如果你在一个特定的页面。我使用了自定义的"url“元素和"link”属性。我喜欢它,因此,如果用户是在page1上,page1项目将下划线粉红色。这是我到目前为止尝试过的:
<script>
function col(){if(top.location.href==document.getElementsByTagName("url")[1].link){this.style.borderBottom="solid #F05&
有没有一种方法可以在脚本中获取一个对象或它的id,使用jQuery或其他什么方法?
例如:
<div id="div1">
<script type="text/javascript">
var obj = ?? // this should be the "div1" div
</script>
</div>
在本例中,obj应等于"div1“(或对象本身)。
另一个:
<p id="paragraph_7">
<script typ
我的JS脚本运行在每个页面上,但我希望它只在post编辑器页面上运行。
function sm_validate_title() {
echo "
<script>
console.log('script working')
...code to validate title and content
</script>";
}
add_action('admin_footer', 'sm_validate_title_client_s