Javascript 如何在从选择框中选择值后显示隐藏文本? .html 我想显示标签主题、等级、类型,填充后选择此角材料框! 当我填写科目等级类型时,这些字段是标签想要显示的

Javascript 如何在从选择框中选择值后显示隐藏文本? .html 我想显示标签主题、等级、类型,填充后选择此角材料框! 当我填写科目等级类型时,这些字段是标签想要显示的,javascript,html,angular,Javascript,Html,Angular,您可以使用ngIf指令,该指令可用于在需要时显示或隐藏html元素 export class NewLectureComponent implements OnInit { isNotify: boolean; showLable(){ this.isNotify = true; } } 因此,当isNotify值为true时,html元素将被添加到doDocument中,如果为false,它将被添加为bindinga模板。您可以使用ngIf指令

您可以使用ngIf指令,该指令可用于在需要时显示或隐藏html元素

export class NewLectureComponent implements OnInit {
  isNotify: boolean;

      showLable(){
         this.isNotify = true;
      }
}
因此,当isNotify值为true时,html元素将被添加到doDocument中,如果为false,它将被添加为bindinga模板。

您可以使用ngIf指令,该指令可用于在需要时显示或隐藏html元素

export class NewLectureComponent implements OnInit {
  isNotify: boolean;

      showLable(){
         this.isNotify = true;
      }
}

因此,当isNotify值为true时,html元素将被添加到DoDocument中,如果为false,它将被添加为bindinga模板。

请尝试此代码,了解如何在从选择框中选择值后显示隐藏文本

<div *ngIf="isNotify">
  <p >Maximum Price exceeding</p> 
</div>
我希望这段代码会有用


谢谢。

请尝试此代码,了解如何在从选择框中选择值后显示隐藏文本

<div *ngIf="isNotify">
  <p >Maximum Price exceeding</p> 
</div>
我希望这段代码会有用


谢谢。

请您正确地澄清/阐述一下。请您正确地澄清/阐述一下。谢谢您的尝试。但是,当我在.ts组件中选择一个选择框值时,我希望识别该值并显示隐藏文本谢谢您的尝试。但是,当我在.ts组件中选择一个选择框值时,我希望识别该值并显示隐藏文本谢谢您的尝试。无论如何,也有一些想法。但我期待角分量的答案。谢谢你的尝试。不管怎么说,也有一些想法。但我希望得到角分量的答案。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Show Hide Elements Using Select Box</title>
<style>
    .box{
        color: #fff;
        padding: 20px;
        display: none;
        margin-top: 20px;
    }
    .red{ background: #ff0000; }
    .green{ background: #228B22; }
    .blue{ background: #0000ff; }
</style>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>
$(document).ready(function(){
    $("select").change(function(){
        $(this).find("option:selected").each(function(){
            var optionValue = $(this).attr("value");
            if(optionValue){
                $(".box").not("." + optionValue).hide();
                $("." + optionValue).show();
            } else{
                $(".box").hide();
            }
        });
    }).change();
});
</script>
</head>
<body>
    <div>
        <select>
            <option>Choose Color</option>
            <option value="red">Red</option>
            <option value="green">Green</option>
            <option value="blue">Blue</option>
        </select>
    </div>
    <div class="red box">You have selected <strong>red option</strong> so i am here</div>
    <div class="green box">You have selected <strong>green option</strong> so i am here</div>
    <div class="blue box">You have selected <strong>blue option</strong> so i am here</div>
</body>
</html>