Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何更改文本区域的背景图像_Javascript_Html_Coding Style - Fatal编程技术网

Javascript 如何更改文本区域的背景图像

Javascript 如何更改文本区域的背景图像,javascript,html,coding-style,Javascript,Html,Coding Style,从选择菜单中选择值时,如何更改文本区域背景图像 <html> <head> <title> Your Title </title> <script> function kool() { `enter code here`abc.style.background="img1.bmp" } </script> </head> <body> <textarea name="abc"> 1

选择
菜单中选择值时,如何更改
文本区域
背景图像

<html>
<head>
<title>  Your Title  </title>

<script>
function kool()
{
`enter code here`abc.style.background="img1.bmp"
}
</script>
</head>
<body>

<textarea name="abc">
1) Make paper airplanes out of the exam. Aim them at the instructor's left nostril. 
2) Bring cheerleaders during an exam.
</textarea>

<select id="xyz" onchange="kool()">
<option value="A">Image 1</option>
<option value="B">Image 2</option>
</select>

</body>
</html>

你的头衔
函数库()
{
`在此处输入代码`abc.style.background=“img1.bmp”
}
1) 用纸飞机代替考试。将它们对准讲师的左鼻孔。
2) 考试时带拉拉队。
图1
图2
这应该可以:

<textarea id="text">
Lorem ipsum dolor sit amet, ...
</textarea>

<select onchange="document.getElementById('text').style.backgroundImage = 'url(' + this.value + ')';">
<option value="image1.png">Image 1</option>
<option value="image2.png">Image 2</option>
</select>

我爱你,我爱你。。。
图1
图2
它应该是:

<script>
function kool(input)
{
   var el = document.getElementById('abc');
   el.style.backgroundImage = 'url(' + input + ')';
}
</script>
</head>
<body>

<textarea name="abc" id="abc">
1) Make paper airplanes out of the exam. Aim them at the instructor's left nostril. 
2) Bring cheerleaders during an exam.
</textarea>

<select id="xyz" onchange="kool(this.value)">
<option value="A.jpg">Image 1</option>
<option value="B.jpg">Image 2</option>
</select>

函数库(输入)
{
var el=document.getElementById('abc');
el.style.backgroundImage='url('+input+');
}
1) 用纸飞机代替考试。将它们对准讲师的左鼻孔。
2) 考试时带拉拉队。
图1
图2

确保路径正确。

在这里,我在哪里指定图像的路径??在
值=“
中!在您的代码中,我如何跟踪我的textarea,我的意思是我的textarea实际上也在iframe中,我给了+1,如何设置我的textarea路径您的textarea在iframe中?尝试以下操作:
window.frames['dork'].getElementById('id').style.etc
,将
id
替换为
iframe
url()中
textarea
属性的实际
id
,这样做不起作用;)(为雅编辑)@Douwe M:谢谢,伙计,我忘了那些话:)