EN

Search
Close this search box.

موستانگ، وحشیِ دوست داشتنی

پاسخ داده شد
0
0

چگونه می توانیم در جی کوئری یک المان را حذف کنیم؟

  • شما باید برای ارسال دیدگاه شوید
پاسخ عالی
0
0

برای حذف یک المان در  جی کوئری از دو متد می توانیم استفاده کنیم.

اولین متد ()remove می باشد.این متد المان و همچنین زیرالمان های آن المان را حذف می کند.

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("p").click(function(){
    $(this).remove();
  });
});
</script>
</head>
<body>

<p>این المان حذف شود</p>

<br>

<button>Remove div element</button>

</body>
</html>

دومین متد ()hide می باشد.

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("p").click(function(){
    $(this).hide();
  });
});
</script>
</head>
<body>

<p>این المان حذف شود</p>

</body>
</html>
  • شما باید برای ارسال دیدگاه شوید
0
0

برای حذف یک المان در  جی کوئری از دو متد می توانیم استفاده کنیم.

اولین متد ()remove می باشد.این متد المان و همچنین زیرالمان های آن المان را حذف می کند.

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("p").click(function(){
    $(this).remove();
  });
});
</script>
</head>
<body>

<p>این المان حذف شود</p>

<br>

<button>Remove div element</button>

</body>
</html>

دومین متد ()hide می باشد.

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("p").click(function(){
    $(this).hide();
  });
});
</script>
</head>
<body>

<p>این المان حذف شود</p>

</body>
</html>
  • شما باید برای ارسال دیدگاه شوید
نمایش 2 نتایج
پاسخ شما
اگر قبلاً حساب کاربری دارید با پر کردن فیلد های زیر یا به عنوان مهمان ارسال کنید.
نام*
ایمیل*
وب سایت